RE: [PHP] Freelance code optimizations

2003-08-14 Thread Chris W. Parker
Robert Cummings on Monday, August 11, 2003 10:55 AM said: > Or are you mistaken in assuming the > following works when perhaps you use this style as part of an echo > statement normally. I apologize. I did not copy and paste my the code I used in my test file into

Re: [PHP] Freelance code optimizations

2003-08-14 Thread Robert Cummings
Comparison to a variable is expectedly slower since the engine must perform a lookup into the running script's variable list. Since a constant doesn't require a lookup it's access time is O( 1 ) whereas the lookup of a variable will lie someplace between O( 1 ) and O( lg n ) depending on the algori

RE: [PHP] Freelance code optimizations

2003-08-14 Thread Robert Cummings
I've never seen a "comma" concatenation operator in PHP and the following when cut and paste to a test PHP script generates a parse error under PHP 4.3.2. Could you elaborate on this operator? Is it part of the PHP 5 engine? Or are you mistaken in assuming the following works when perhaps you use t

RE: [PHP] Freelance code optimizations

2003-08-14 Thread Robert Cummings
On Mon, 2003-08-11 at 13:29, Chris W. Parker wrote: > > * while loop > > $ctr = 0; > $val = 0; > while($ctr<10) > { > $val++; > $ctr++; > } > > ** for loop > > $val = 0; > for($ctr=0;$ctr<10;$ctr++) > { > $val++; > } > I get the following results (very consistently +

RE: [PHP] Freelance code optimizations

2003-08-14 Thread Chris W. Parker
Jay Fitzgerald on Saturday, August 09, 2003 10:05 PM said: > I am a somewhat slow learner in that I cannot learn from reading - the > stuff on functions, for example, is confusing to me - I can only learn > by examples with explanations of why certain things are done

Re: [PHP] Freelance code optimizations

2003-08-12 Thread Curt Zirzow
* Thus wrote Ray ([EMAIL PROTECTED]): > > so if $a is something like the size of an array or another thing that affects > the number of times the loop needs to be run. then if you can, reverse the > order of the loop so you can compare to 0 (or another constant) > > $a = 1000; > $i = $a; >

Re: [PHP] Freelance code optimizations

2003-08-11 Thread Ray
also, if you can compare to a constant, there is a notable difference as well. real0m10.268s user0m10.000s sys 0m0.030s real0m7.057s user0m6.880s sys 0m0.020s so if $a is something like the size of an array or another thing that affects the number of times the loop nee

RE: [PHP] Freelance code optimizations

2003-08-11 Thread Chris W. Parker
Robert Cummings on Monday, August 11, 2003 11:11 AM said: > $i = 0; > while( $i++ < 1000 ){} [snip] > Notice the large difference when the incrementation occurs within the > while check itself. Wow, look at that. I had no idea you could even do that. Now my pa

RE: [PHP] Freelance code optimizations

2003-08-11 Thread Robert Cummings
In that case it makes perfect sense since a concatenation is not actually performed. The loops stuff though might be more tricky to determine reasoning. I imagine it has to do with the execution tree and references being created at various stages. Probably the for loop has an extra step or two whic