Re: Include file

From: Date: Wed, 30 Mar 2005 21:45:32 +0000
Subject: Re: Include file
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-211919@lists.php.net to get a copy of this message
Because I'm bored, I decided to test the theory. AMD 3200xp 1.5gb Memory RHEL AS 3 I ran the test 20 times, and 18 of those times, double quotes were faster than single quotes. Don't always trust what you read. Not to mention the fact that the 'faster' of the two was 'faster' by an average of less than .003 seconds to include 1000 files. <?php function microtime_float() { list ( $usec, $sec ) = explode ( " ", microtime() ); return ( ( float ) $usec + ( float ) $sec ); } for ( $i = 0; $i < 1000; $i++ ) { $fp = fopen ( "file_" . $i . ".php", "w" ); fwrite ( $fp, "<?php\n\n\n?>" ); fclose ( $fp ); } $single_start = microtime_float(); for ( $i = 0; $i < 1000; $i++ ) { include ( 'file_' . $i . '.php' ); } $single_end = microtime_float(); $double_start = microtime_float(); for ( $i = 0; $i < 1000; $i++ ) { include ( "file_" . $i . ".php" ); } $double_end = microtime_float(); $single = $single_end - $single_start; $double = $double_end - $double_start; echo ( "Single Quotes : " . $single . " seconds.<br />\n" ); echo ( "Double Quotes : " . $double . " seconds.<br /><br />\n" ); if ( $double > $single ) { $time = $double - $single; echo ( "Single Quotes are " . $time . " seconds faster than double quotes." ); } else { $time = $single - $double; echo ( "Double Quotes are " . $time . " seconds faster than single quotes." ); } ?> -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 john@kegworks.com

« previous php.general (#211919) next »