|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-05-31 17:09 UTC] dpfender44 at gmail dot com
Description: ------------ My function scan_dir() uses opendir(), chdir(), readdir(), is_dir(), closedir() to scan for files on the server. PHP version 7.4.0-dev does the same scan as version 7.3.6 but takes about 100 times longer. This is all done on the same server, but just switching between PHP versions on 5/31/19. The extra time seems to be spent doing readdir(). Test script: --------------- http://djpsrc.djpnet.dyndns.org/test_scan_dir.php.txt Expected result: ---------------- PHP version 7.3.6 Operating System Microsoft Windows [Version 10.0.17763.503] File search types: .mp4|.webm|.mp3|.wav|.mid|.txt Units of seconds (Unix timestamp from microtime()): Start file search time (1559247589.134) End file search time (1559247589.1699) Elapsed time (0.035879135131836) Resulting file match count (777) Actual result: -------------- PHP version 7.4.0-dev Operating System Microsoft Windows [Version 10.0.17763.503] File search types: .mp4|.webm|.mp3|.wav|.mid|.txt Units of seconds (Unix timestamp from microtime()): Start file search time (1559320102.0205) End file search time (1559320105.3702) Elapsed time (3.3497362136841) Resulting file match count (777) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 18:00:01 2025 UTC |
Thanks for reporting this issue. I can confirm a severe performance regression with the following script: <?php $start = hrtime(true); $count = scandirrec('D:/git/php/php-src/ext'); $end = hrtime(true); printf("%d files found in %f sec\n", $count, ($end-$start)/1e9); function scandirrec($dir) { $count = 0; $owd = getcwd(); chdir($dir); $files = scandir('.'); foreach ($files as $file) { if ($file[0] === '.') continue; if (is_dir($file)) { $count += scandirrec("$dir/$file"); } else { $count++; } } chdir($owd); return $count; } ?> Running with php-7.3.6-nts-Win32-VC15-x64, I get something like: 14105 files found in 0.245927 sec but with php-7.4-nts-windows-vs16-x64-r7a64150 and php-7.4-nts-windows-vc15-x64-re2f8d90 (latest VC 15 snap), something like: 14105 files found in 1.028066 sec (all three PHP versions running without php.ini)