(Pathinfo vs fnmatch第2部分)Windows和Mac上的速度基准颠倒了 [英] (Pathinfo vs fnmatch part 2) Speed benchmark reversed on Windows and Mac

查看:73
本文介绍了(Pathinfo vs fnmatch第2部分)Windows和Mac上的速度基准颠倒了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在上一个问题中,对pathinfo和fnmatch函数进行了基准测试,所有答案都出炉了与我的基准测试结果相反.

On a previous question the pathinfo and fnmatch functions were benchmarked and the answers all came out opposite to my benchmark results.

您可以在此处通过基准代码读取不同的结果: pathinfo与fnmatch

You can read the different results with the benchmark code here: pathinfo vs fnmatch

直到在运行Vista的计算机上运行相同的代码之前,我无法解决.然后,结果与其他用户匹配.我的主机是Mac.

I couldn't work it out until I ran the same code on a machine running vista. The results then matched the other users. My main machine is a mac.

所以,我的问题是:

  • 为什么我们会得到这两个不同的结果?
  • 这可以适用于其他功能吗?

推荐答案

我们为什么要得到这两种不同 结果?

Why do we get these two different results?

fnmatch应该映射到操作系统的基础fnmatch命令(Windows没有这样的命令,并且直到PHP 5.3才可用).苹果执行该命令的速度必须较慢.

fnmatch should be mapped to the OS's underlying fnmatch command (Windows has no such command and was unavailable until PHP 5.3). Apple's implementation of the command must be less speedy.

这可以适用于其他功能吗?

Could this apply to other functions?

您可以检查 glob()来解决速度问题还对文件名执行正则表达式.

You could check glob() for speed issues as it also performs regex on filenames.

编辑:Glob不进行正则表达式.好吧,世界. (感谢salathe)

Glob does not regex. It, well, globs. (thanks to salathe)

这篇关于(Pathinfo vs fnmatch第2部分)Windows和Mac上的速度基准颠倒了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆