Test: glob(no_sort) vs DirectoryIterator
No Description
View test history (1) Run this test again Return to test menuResult: Discarded
The test labeled "glob(GLOB_NOSORT)" was the faster by 0.0007 seconds, (0.130% faster)
The glob(GLOB_NOSORT) test took 0.5749 seconds.
The DirectoryIterator() test took 0.5757 seconds.
Nitty-Gritty
Each test case ran 20 random code order iterations consisting of 137,766 loops for a total of 2,755,320 runs.
- Line execution difference (0.000000) milliseconds.
- Avg difference (0.037) milliseconds per 137,766 loops.
- Total difference 0.75 milliseconds for 2,755,320 loops
The iteration variablity for Code 1 was (4.4609) milliseconds and Code 2 was (4.0739) milliseconds. The lower and the closer together there values are the more accurate the results are.
Code
The first test, "DirectoryIterator()", was:
clearstatcache(); $result = array(); foreach (new DirectoryIterator($GLOBALS['basedir'] . '/tests') as $file) { if ($file->isDir()) continue; $result[] = $file->getFilename(); }
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; } }