Andreas Korthaus: Verzeichnis opendir problem

Beitrag lesen

Hallo XaraX!

btw. der Bug in scandir() wurde behoben: http://bugs.php.net/bug.php?id=31515

Messung vor dem Bugfix:

scandir (loop:1, files:10000)
mem: 40M
time: 0.40674495697021s

my_scandir (loop:1, files:10000)
mem: 1M
time: 0.17293095588684s

scandir (loop:100, files:10000)
mem: 40M
time: 41.659919977188s

my_scandir (loop:100, files:10000)
mem: 1M
time: 20.631703853607s

Messung nach dem Bugfix:

scandir (loop:1, files:10000)
mem: 1M
time: 0.050025939941406s

scandir (loop:100, files:10000)
mem: 1M
time: 8.0913100242615s

function my_scandir($dir) {  
        $dh  = opendir($dir);  
        while (false !== ($filename = readdir($dh))) {  
                $files[] = $filename;  
        }  
        sort($files);  
        return $files;  
}

Selbst ohne sort() in my_scandir() ist scandir() noch schneller, obwohl da in jedem Fall sortiert wird.

Grüße
Andreas

--
SELFHTML Linkverzeichnis: http://aktuell.de.selfhtml.org/links/