(Pathinfo 与 fnmatch 第 2 部分)Windows 和 Mac 上的速度基准相反
在上一个问题中,对 pathinfo 和 fnmatch 函数进行了基准测试,结果都与我的基准测试结果相反。
您可以在此处使用基准代码读取不同的结果: pathinfo 与 fnmatch
我无法解决这个问题,直到我在运行 vista 的计算机上运行相同的代码。然后结果与其他用户相匹配。我的主机是mac。
所以,我的问题是:
- 为什么我们会得到这两个不同的结果?
- 这可以适用于其他功能吗?
On a previous question the pathinfo and fnmatch functions were benchmarked and the answers all came out opposite to my benchmark results.
You can read the different results with the benchmark code here:
pathinfo vs fnmatch
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.
So, my questions are:
- Why do we get these two different results?
- Could this apply to other functions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
fnmatch 应映射到操作系统的底层 fnmatch 命令(Windows 没有此类命令,并且在 PHP 5.3 之前不可用)。苹果执行该命令的速度肯定要慢一些。
您可以检查 glob() 的速度问题,因为它也执行正则表达式关于文件名。
编辑: Glob 不使用正则表达式。它,嗯,球状的。 (感谢萨拉特)
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.
You could check glob() for speed issues as it also performs regex on filenames.
Edit: Glob does not regex. It, well, globs. (thanks to salathe)