(Pathinfo vs fnmatch part 2) Speed benchmark reversed on Windows and Mac

流过昼夜 提交于 2020-01-06 05:17:12

问题


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?

回答1:


Why do we get these two different results?

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?

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)



来源:https://stackoverflow.com/questions/2759548/pathinfo-vs-fnmatch-part-2-speed-benchmark-reversed-on-windows-and-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!