ID: 29255
User updated by: borreo at softhome dot net
Reported By: borreo at softhome dot net
Status: Open
Bug Type: Performance problem
Operating System: Windows 2000
PHP Version: 5.0.0
New Comment:
Disabling allow_url_fopen doesn't change a thing.
Previous Comments:
------------------------------------------------------------------------
[2004-07-19 12:03:35] borreo at softhome dot net
Description:
------------
Not really a bug, the code works.
The stat function, if used on a network file, is much slower in PHP5
than in PHP 4.3.7.
On my system, PHP 5.0 takes 20 seconds to stat 1000 files.
With PHP 4.3.7, this takes 2 seconds.
If I use a local directory (e.g. C:\work) rather than a network drive,
then there is no visible difference in performance between PHP 4.3.7
and PHP 5.
In order to produce accurate tests, I installed both version of PHP on
the same machine, in different directories, using a common php.ini
Reproduce code:
---------------
// I: points to a network drive
chdir( 'I:/work' ) ;
$ListOfFiles = rglob( ".", "*" ) ;
$StartTime = time() ;
foreach( $ListOfFiles as $i )
stat( $i ) ;
$ElapsedTime = time() - $StartTime ;
die( "Seconds=$ElapsedTime\n" );
// Recursive version of glob
function rglob( $Dir, $Pattern )
{
$Files = glob( "$Dir/$Pattern", 0 ) ;
$Directories = glob( "$Dir/*", GLOB_ONLYDIR ) ;
if ( is_array( $Directories ) )
{
foreach( $Directories as $SubDir )
{
$SubFiles = rglob( $SubDir, $Pattern ) ;
if ( is_array( $SubFiles ) )
$Files = array_merge( $Files, $SubFiles ) ;
}
}
return $Files;
}
Actual result:
--------------
With PHP 5.0: Seconds=20
With PHP 4.3.7: Seconds=2
If I change the current directory to a local dir (e.g. C:\work) then
there is no difference between PHP 4.3.7 and PHP 5.0:
With PHP 5.0: Seconds=2
With PHP 4.3.7: Seconds=2
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29255&edit=1