Forum Moderators: coopster
<?php
$totaltimes=20;
$timeparts = explode(' ',microtime());
$starttime = $timeparts[1].substr($timeparts[0],1);
for ($x=1;$x<=$totaltimes; $x++) {
// Put code to benchmark here
}
$timeparts = explode(' ',microtime());
$endtime = $timeparts[1].substr($timeparts[0],1);
echo ("Your code ran at about ".(bcsub($endtime,$starttime,6)/$totaltimes)." seconds per loop")
?>
MySQL will NOT cache a query with RAND() or NOW() in it for example, so it has to do the query each time. If it's a "select * from table" without the rand, then it will cache the result until the table is updated.
I think the answer depends on how many rows in the table.