问题
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