Re: Freelance code optimizations

From: Date: Mon, 11 Aug 2003 21:25:21 +0000
Subject: Re: Freelance code optimizations
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-159196@lists.php.net to get a copy of this message
* Thus wrote Ray (ray.list@powerweb.net): > > 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) > > <?php > $a = 10000000; > $i = $a; > while( $i-- > 0 ){} > ?> > real 0m7.111s > user 0m6.870s > sys 0m0.040s Interesting approach... yet: My results for above 31.017u 0.007s 0:31.14 99.5% 1544+918k 0+0io 0pf+0w You can optimize it some more: <?php $a = 10000000; $i = $a; while( $i-- ){} ?> these results 19.008u 0.031s 0:19.58 97.1% 1544+918k 0+0io 0pf+0w Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#159196) next »