Re: Re: Newbie question about <?= ?>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Satyam wrote:
for ($x=0;$x<1000;$x++) {
   echo ' <tr><td>X is ' , $x , '</td></tr>';
}
This seems to be a hair faster. I extended the test to 10000 requests (still concurrency 10) to make the test a little more reproducible:

echo str,var,str did 604.65 requests a second where <tr><td><?= $x ?></td></tr> did 599.63 requests a second. I also tried echo str . var . str, and it came in at about 584.55 requests a second. printf("str %i str",var) came out at 547.01 requests a second and printf("str %s str",var) was only 452.03 requests a second.
Can you try and time that one so we have comparable results? This one should be second best:

for ($x=0;$x<1000;$x++) {
   echo "<tr><td>X is $x</td></tr>";
}
Approximately 330 (?!) requests a second for that one.
Back again to what would be 'longer', well, in your example, the whole header, up to the loop itself should be faster if sent out of PHP. Likewise, you could echo $buffer right after the loop, drop out of PHP and send the footer as plain HTML. This, of course, is harder to time since it happens only once. I admit though that I did time the options I listed and on the 'dropping in and out of PHP' I'm relying on the PHP manual ( see http://www.php.net/manual/en/language.basic-syntax.php, the first paragraph after the examples) and the source of the lexical scanner, which supports that, though your numbers do contradict it. Interesting.
I'm not sure that my results would count as contradictory - I'm running APC which would likely throw performance related numbers out of whack as compared to out-of-the-box PHP.

Because of that, I wouldn't recommend anyone take my numbers too seriously - they're just an example taken from my server: 1.8 GHz SMP/1G/RAID5/Linux 2.6.17.7/Apache 2.2.3/PHP 5.1.6/APC 3.0.12p2. Anyone else's results would probably vary widely.

jon

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux