ID:               28901
 Updated by:       [EMAIL PROTECTED]
 Reported By:      sprice at wisc dot edu
-Status:           Open
+Status:           Bogus
 Bug Type:         Performance problem
 Operating System: Mac OS X 10.3.4
 PHP Version:      4.3.7
 New Comment:

The internal include_once() performs additional checks which are not
performed by your "improved" version.  For example, your version does
not account for symbolic links, non-case sensitive file systems, or
current working directory and include paths (when used with relative
pathnames).

The good news is that the basic format of your "already included
registry" is the essentially the same as what's used internally, so you
were on the right track at least.


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

[2004-06-23 22:43:10] sprice at wisc dot edu

Description:
------------
I use include_once() and require_once() quite a bit, as 
I would guess many others do. During a single page load, 
I might call for the same file from many functions, just 
to make sure things get defined correctly and in the 
correct order. I did some testing today, and I noticed 
that they both could be close to *two orders of 
magnitude* faster for multiple inclusions.

I have attached the PHP code that I used to test this. 
On my computer, when I use include_once() inside the for 
loop, it takes about 6.0 seconds. When I use 
improved_include_once(), it takes about 0.08 seconds. 
The same goes for require_once().

Could/Should something like this be implemented in PHP? 
It seems like a good idea, and you guys could do a more 
efficient implementation than I am able to do.

Reproduce code:
---------------
function getMicroTime(){
        list($usec, $sec) = explode( ' ', microtime() );
        return ((float)$usec + (float)$sec);
}

function improved_include_once($filename){
        if(!isset($GLOBALS['included_files'][$filename])){
                include_once($filename);
                $GLOBALS['included_files'][$filename] = TRUE;
        }
}

$start_time = getMicroTime();

for($i = 0; $i < 10000; $i++){
        include_once('my_file.inc');
}

echo (getMicroTime() - $start_time);



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


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

Reply via email to