Also, I think that:
"stuff\n";
would be faster than:
'stuff'."\n";
(Though yes, 'stuff' is faster than "stuff")
Printable View
Also, I think that:
"stuff\n";
would be faster than:
'stuff'."\n";
(Though yes, 'stuff' is faster than "stuff")
Output:Code:<?php
function avg($arr) {
$total = 0;
for($i = 0; $i < count($arr); ++$i)
$total += $arr[$i];
return $total / count($arr);
}
$times1 = array();
$times2 = array();
for($i = 0; $i < 10000; ++$i) {
$s = microtime();
'Hello' . "\n";
array_push($times1, microtime() - $s);
$s = microtime();
"Hello\n";
array_push($times2, microtime() - $s);
}
echo 'Average for single/double concatenation: ' . avg($times1) . "\n" .
'Average for only double: ' . avg($times2) . "\n";
?>
It is.Code:Average for single/double concatenation: 1.7569E-06
Average for only double: 1.6627E-06