Wednesday, 24 June 2009

PHP Beauty

Hi Readers,

Google announced this article collection recently: I thought 'What the heck, let's bechmark something.', and took a small experiment:

<div style="display:none;">

$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;

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:)


No comments:

Post a Comment

Note: only a member of this blog may post a comment.