Created
November 25, 2010 09:10
-
-
Save caefer/715114 to your computer and use it in GitHub Desktop.
benchmarks RecursiveDirectoryIterator against glob()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$testDir = dirname(__FILE__).'/test/'; | |
$startTime = microtime(true); | |
$touches = 0; | |
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($testDir)) as $filepath) | |
{ | |
touch($filepath); | |
$touches++; | |
} | |
printf("Touched %d files in %.4f seconds with iterators".PHP_EOL, $touches, microtime(true) - $startTime); | |
$startTime = microtime(true); | |
$touches = 0; | |
for($i=0; $i<5; $i++) | |
{ | |
foreach(glob($testDir.'*.*') as $filepath) | |
{ | |
touch($filepath); | |
$touches++; | |
} | |
$testDir .= '*/'; | |
} | |
printf("Touched %d files in %.4f seconds with glob".PHP_EOL, $touches, microtime(true) - $startTime); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment