|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-02-05 22:45 UTC] 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,... PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 11:00:01 2025 UTC |
$_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 */