![]() |
Faster way to list dir ?
Good day to you all,
I have a piece of code which read a directory and return a list of file and folders that is with in recursively. This code is very slow. Maybe you can help me make it go faster ? PHP Code:
|
The only way I can immediately identify to optimize it is to hard code the ignore list opposed to reading an array every time, but that advantage will probably be negligible at best. It takes PHP a long time to do these things, that might just be a scripting language thing.
This is why I hate shared hosting, you do not have the ability to make programs for the server to run that execute more tedious tasks like the one you have here. I wrote a VB application to do something fairly similar and it could do very fast (an entire hard drive in <2min). edit: Try appending your output to a single string then outputting it all at the end. You might be surprised how long it takes it to continuously output text. |
You can try the DirectoryIterator class or the Glob() function to see if they speed anything up.
|
Quote:
|
Have you tried the php5 SPL library?
PHP Code:
http://us3.php.net/manual/en/class.r...ryiterator.php Just running some microtime tests on it, it will parse through 380 directories containing 3700 files in a little over 2 seconds. |
| All times are GMT. The time now is 10:44 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0