NYCPHP Meetup

NYPHP.org

[nycphp-talk] Variables syntax

Tim McEwen php at tmcode.com
Tue Nov 1 09:51:22 EST 2005


Dan,

AB was set to repeat the request 10 times (-n 10)  and I also tried  
running the test a few times (letting the load settle between tests)  
on a few machines.   The results were consistent

All that being said, I must admit to being under the influence of  
*WAY* too much caffeine on Friday.   Consequently I'm happy to eat  
crow and admit my test was a little skewed. The problem was with the  
size of string I was constructing:

for($i=0; $i<100000; $i++)    $string="A{$string}B";

By the end of the test, $string was a couple hundred kbytes in  
length.   If you run the same test with a fixed string that does not  
grow, it looks like the glue method runs a few ms faster than the  
double quoted method.  This leads me to believe that the concatenate  
operator only gets slower when working with large variables and for  
small variables it really doesn't matter.

On a side-note,  it would be fun to see some more definitive  
benchmarks on different aspects of the PHP language.  In the process  
of teaching the php essentials courses I always get a few questions  
on whether double quotes are slower than singles, foreach vs while vs  
for loops on arrays,   echo vs print,   include vs include_once,  
etc.   While the answers are fairly intuitive, it would be nice to  
measure the actual impact in a slightly more scientific fashion.    
I'm guessing the results would also vary from version to version  
too.  Maybe when I run into some spare time....  (ha!)

-Tim McEwen


On Oct 31, 2005, at 7:58 PM, Daniel Convissor wrote:

> Hey Tim:
>
> On Fri, Oct 28, 2005 at 04:50:56PM -0400, Tim McEwen wrote:
>
>>
>> ab -n 10 http://localhost/test_a.php
>> ...
>> Time per request:       28574.142 [ms] (mean)
>> ...
>>
>> ab -n 10 http://localhost/test_b.php
>> ...
>> Time per request:       14057.574 [ms] (mean)
>> ...
>>
>
> How many times did you run your test?  Things vary between requests.
>
> --Dan
>
> -- 
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>             data intensive web and database programming
>                 http://www.AnalysisAndSolutions.com/
>  4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>




More information about the talk mailing list