| Posted by Carl Vondrick on 04/14/06 00:30 
Andy Jeffries wrote:> Anyway, my point was - undeniably faster, but how much so...  Anyone got
 > numbers?
 In large numbers, it is significant.  Ran under Kubuntu Linux with PHP 5.1.2
 with 1GB RAM and 3.2Ghz processor:
 
 Output:
 S Diff: 11.428... (single quotes)
 D Diff: 19.623... (double quotes)
 
 Script:
 <?php
 $s_start = microtime(true);
 
 for ($x = 0; $x < 99999; $x++)
 {
 echo 'Hello.  How are you?<br />';
 }
 
 $s_end = microtime(true);
 
 $d_start = microtime(true);
 
 for ($x = 0; $x < 99999; $x++)
 {
 echo "Hello.  How are you?<br />";
 }
 
 $d_end = microtime(true);
 
 echo 'S Diff: ' . ($s_end - $s_start) . '<br />';
 echo 'D Diff: ' . ($d_end - $d_start) . '<br />';
 ?>
 
 
 So, single quotes wins hands down.  To compare echo vs print:
 
 Output:
 E Diff: 12.626... (echo)
 P Diff: 15.637... (print)
 
 <?php
 $e_start = microtime(true);
 
 for ($x = 0; $x < 99999; $x++)
 {
 echo 'Hello.  How are you?<br />';
 }
 
 $e_end = microtime(true);
 
 $p_start = microtime(true);
 
 for ($x = 0; $x < 99999; $x++)
 {
 print 'Hello.  How are you?<br />';
 }
 
 $p_end = microtime(true);
 
 echo 'E Diff: ' . ($e_end - $e_start) . '<br />';
 echo 'P Diff: ' . ($p_end - $p_start) . '<br />';
 ?>
 
 The fastest is echo with single quotes.
 
 --
 Carl Vondrick
 Web-Engineer
 www.carlsoft.net
 [Back to original message] |