Created
May 19, 2014 13:43
-
-
Save borislav-angelov/8d74dde8a9f13d341266 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| $dir = "C:\\"; | |
| $start = microtime(true); | |
| function recursive_readdir($dir) { | |
| $dh = opendir($dir); | |
| while (false !== ($filename = readdir($dh))) { | |
| if ($filename != '.' && $filename != '..') { | |
| if (is_dir($dir . $filename)) { | |
| recursive_readdir($dir . $filename . '\\'); | |
| } else { | |
| //echo $dir . $filename . "\n"; | |
| } | |
| } | |
| //echo $filename . "\n"; | |
| //$files[] = $filename; | |
| } | |
| closedir($dh); | |
| } | |
| recursive_readdir($dir); | |
| $total = microtime(true) - $start; | |
| echo $total; | |
| echo "\n\n"; | |
| $start = microtime(true); | |
| // Use Recursive functions | |
| $iterator = new RecursiveIteratorIterator( | |
| new RecursiveDirectoryIterator($dir), | |
| RecursiveIteratorIterator::SELF_FIRST | |
| ); | |
| foreach ($iterator as $item) { | |
| // Skip dots | |
| if ($iterator->isDot()) { | |
| continue; | |
| } | |
| // Add to archive | |
| if ($item->isDir()) { | |
| } else { | |
| //echo $iterator->getSubPathName() . "\n"; | |
| } | |
| } | |
| $total = microtime(true) - $start; | |
| echo $total; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment