views:

24

answers:

1

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: http://stackoverflow.com/questions/2693428/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?
A: 

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)

webbiedave
Globbing is not *performing regex* at all.
salathe