Re: PHP URL issues

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

 



There are lies, damned lies and statistics.  Had he known about benchmarks!

I have already tried different ways of producing output and I completely disagree that concatenating the pieces and then echoing them is the best. In a first try, I found that echoing the separate parts as arguments to echo with commas in between was the fastest and variable interpolation within double quotes strings (or heredoc) was fastest than concatenation. Nevertheless, in a later trial, the numbers which were so clearly in favor of echo with multiple arguments, turned only slightly better, not enough to justify the loss of flexibility of building up a string first and having the option of manipulating it.....

This last sentence was confusing, lets see. When writing functions, you might either have them do the echo themselves or returning a string. The first is fastest, the second offers flexibility. If the first is really much faster, I'm willing to do away with the flexibility, which is no more than a potencial benefit, since 90% of the time I might have nothing at all to do with the return value of the funcion and, if really needed, I might use output buffering. Neverhteless, if the straight echoes are not that much faster, I'd rather keep an ace in my sleeve and go with returning strings. In my first trial, the result was conclusive, it was about 4 to 1, in the second, it was about 20% faster. The first was done on my own personal machine, a Windows machine doing nothing else, the second on my ISP shared hosting with an unknown load.

I might say that my test on my own idle machine was the most representative, since it didn't have to deal with external issues such as competing for external resources, but then, that competition is really part of life. Though avoiding the memory shuffling of doing many string concatenations, doing echoes with multiple arguments might require the interpreter to negotiate access to IO buffers more often than building the whole page in memory and then getting it echoed just once. And I am sure that the way Windows and Linux handles IO with Apache is quite different, so, which benchmark is really representative?

I am sure that some benchmarks are quite representative, independent of platforms. For example, it would make sense that doing an exact equality (triple =) should be faster than a plain equality. The first fails straight away if types are different and in no case is any conversion made. In the second, if the types don't match conversions need to be made first (after figuring out which one to make) so logic indicates it should take longer. Nevertheless, I don't feel like testing it out since the results, as my previous experience indicate, seem to be so uncertain.

I'm not even arguing whether it makes sense or not in trying to shave off a few ticks of the clock. I am sure that a machine handling who knows how many users requests simultaneously will appreciate any little help, actually, I'm not sure I am actually looking for answers because, as far as I know, the answer is: it depends

Satyam



----- Original Message ----- From: "Richard Lynch" <ceo@xxxxxxxxx>
To: "Steve" <steve@xxxxxxxxxxxx>
Cc: <php-general@xxxxxxxxxxxxx>
Sent: Wednesday, March 14, 2007 10:07 AM
Subject: Re:  PHP URL issues


On Tue, March 13, 2007 9:31 am, Steve wrote:
This may or may not help, but here's a few things to note:

1) I would avoid placing variable output in double quoted strings.
While not
important for smaller scripts, doing a large number of outputs like
this
causes a decent performance hit. In fact, I wouldn't use double quotes
ever
in php. Instead, strive for something like:

echo '<b><a href="test.php?term='.$letter_value.'">'.$letter_value.'
&nbsp;</a></b>';

Have you benchmarked this, or can you provide a link to others'
benchmarks demonstrating this perofmrnace hit?...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.11/721 - Release Date: 13/03/2007 16:51



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