#44056 [Fbk->Opn]: Get file content

From: Date: Wed, 06 Feb 2008 18:13:55 +0000
Subject: #44056 [Fbk->Opn]: Get file content
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-122040@lists.php.net to get a copy of this message
 ID:               44056
 User updated by:  raphpell at cario dot fr
 Reported By:      raphpell at cario dot fr
-Status:           Feedback
+Status:           Open
 Bug Type:         Performance problem
 Operating System: Windows Vista
 PHP Version:      5.2.5
 New Comment:

$_ENV [ 'nFiles' ] = 0 ;
$_ENV [ 'nFolders' ] = 0 ;
$sPath = $prefixe . './' ; // define a file system

function _getmicrotime ( ) {
	list ( $usec, $sec ) = explode ( " " , microtime ( )) ;
	return ( ( (float) $usec + (float) $sec ) * 1000 ) ;
	};
	
function doSomething ( $sPath ) {
	$_ENV [ "nFolders" ]++ ;
	$a = glob ( $sPath . "*" ) ;
	if ( $a ) 
		while ( list (, $sFile ) = each ( $a )){
			if ( is_dir ( $sFile ) AND ! in_array ( $sFile , Array ( "." , ".."
)))
				doSomething ( $sFile . "/" ) ;
			if ( is_file ( $sFile )){
				$s = file_get_contents ( $sFile ) ;
				$_ENV [ "nFiles" ]++ ;
				}
			}
	};
	
$nStart = _getmicrotime ( ) ;
if ( is_dir ( $sPath )) doSomething ( $sPath ) ; else die ( $sPath ) ;
echo 
	' - time: '. (int)( _getmicrotime ( ) - $nStart ) . 'ms ' .
	' - Files: '. $_ENV [ "nFiles" ] .
	' - Folders: '. $_ENV [ "nFolders" ] ;

/*
EXECUTION TIME

[PHP 4.3.10]
2848.597 ms
2915.554 ms
2798.933 ms

[PHP 5.2.5]
11469.610 ms
11199.461 ms
11227.722 ms
*/


Previous Comments:
------------------------------------------------------------------------

[2008-02-06 08:13:10] derick@php.net

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

------------------------------------------------------------------------

[2008-02-05 22:45:45] raphpell at cario dot fr

Description:
------------
I handle my filesy stem :
- 2000 files
- 2000 folders

With PHP 4.3.3 my scripts take 5 secondes
With PHP 5.2.5 35 secondes...
I use fopen, file_get_contents ( ob_start + include )

I zip my site, create my db with my filesystem,...



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44056&edit=1


Thread (4 messages)

« previous php.bugs (#122040) next »