Google announced this article collection recently: http://code.google.com/speed/articles/optimizing-php.html I thought 'What the heck, let's bechmark something.', and took a small experiment:
<div style="display:none;">
<?php
$sum = 0;
$count = 10000;
$iteration = 100;
for ($j = 0; $j < $iteration; $j++) {
$t1 = microtime(TRUE);
for ($i = 0; $i < $count; $i ++) {
//print "aaa"."bbb"."ccc"."ddd"."eee"."fff"."ggg"."hhh";
echo 'aaa','bbb','ccc','ddd','eee','fff','ggg','hhh';
}
$t2 = microtime(TRUE);
$sum += $t2 - $t1;
}
?>
</div>
<?php
var_dump($sum / $iteration);
And the results were quite nice: 0.026 against 0.017. So that is why echo still rocks, because with echo you can use comma instead of period. Never heard of commas for echo before. This is a PHP magic:)
Night,
Peter
No comments:
Post a Comment
Note: only a member of this blog may post a comment.