RE: [PHP] RE: newbie alternate row colours in dynamic table -- timed tests
| From: | Chris Hayes | Date: | Sun, 06 Apr 2003 19:18:39 +0000 |
| Subject: | RE: [PHP] RE: newbie alternate row colours in dynamic table -- timed tests | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142608@lists.php.net to get a copy of this message | ||
haha what a dedication :-)
and this is for 100000 iterations - PHP is pretty fast then. cool. thanks for testing!
At 01:45 6-4-2003, you wrote:
I had to know... ;-) Output:version one: 0.56761503219604 seconds version two: 0.3099730014801 secondsversion three: 0.36320495605469 secondss So the boolean (V2)is faster: Mine is slightly slower by a 'smidge' (0.06 seconds) Top one is cleanest but slower. --- test --- <?php function getmicrotime(){list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec);} $ITERATIONS = 100000; $time_start = getmicrotime(); for ($i = 1; $i < $ITERATIONS; $i++) {$bgcolor = ($bgcolor == '#E3E8F0') ? '#C7D0E2' : '#E3E8F0';} $time_end = getmicrotime(); $time1 = $time_end - $time_start; echo "version one: \t$time1 seconds<P>\n"; $time_start = getmicrotime(); $tf = TRUE; for ($i = 1; $i < $ITERATIONS; $i++) {$tf=!$tf; ($tf) ? "'C7D0E2" : "E3E8F0";} $time_end = getmicrotime(); $time2 = $time_end - $time_start; echo "version two: \t$time2 seconds<P>\n"; $time_start = getmicrotime(); $r = 0; for ($i = 1; $i < $ITERATIONS; $i++) {(($r++ % 2 == 0) ? "'C7D0E2" : "E3E8F0");} $time_end = getmicrotime(); $time3 = $time_end - $time_start; echo "version three: \t$time3 seconds<P>\n"; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php