Historical Results
Based on (6) saved test runs, The test labeled "scandir()" was (on average) the faster by 0.0041 seconds, (0.409% faster)
The scandir() test took 0.994 seconds.
The glob(GLOB_NOSORT) test took 0.9981 seconds.
Nitty-Gritty
Each test case ran 20 random code order iterations consisting of 275,063 loops for a total of 5,501,253 runs.
- Line execution difference (0.000001) milliseconds.
- Avg difference (0.000) milliseconds per 275,063 loops.
- Total difference 4.08 milliseconds for 5,501,253 loops
The iteration variablity for Code 1 was (0.0000) milliseconds and Code 2 was (0.0000) milliseconds. The lower and the closer together there values are the more accurate the results are.
Code
The first test, "scandir()", was:
clearstatcache(); $result = array(); foreach (scandir($GLOBALS['basedir'] . '/tests') as $file) { if (!is_dir($basedir . '/' . $file)) { $result[] = $file; } }
The second test, "glob(GLOB_NOSORT)", was:
clearstatcache(); $result = array(); foreach (glob($GLOBALS['basedir'] . '/tests/*', GLOB_NOSORT) as $file) { if (!is_dir($file)) { $result[] = $file; } }