Re: Speed tests? RAM usage displays?
| From: | Pekka Saarinen | Date: | Fri, 21 Jun 2002 15:30:45 +0000 |
| Subject: | Re: Speed tests? RAM usage displays? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-103290@lists.php.net to get a copy of this message | ||
At 6/21/2002, you wrote:
PS> What about execution time in ms (with breakpoints)?
PS> And is there way to measure MySQL query speed in ms?
u can use microtime function
function getMicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
in your head of your script than call:
$start = getMicrotime();
and then in the end of script
$stop = getMicrotime();
$diff = $stop - $start;
echo "Execution time was: ".$diff;
Thanks! That was really useful. I placed it around the biggest/most complex MySQL query on the code and found out that the biggest slow down there was due ORDER BY command (and not LIKE I thought was). So, I removed the ORDER BY and did array sorting using PHP (PHP did it in less than a millisecond) and got this query speed down from .25s to .07s
Optimising can be so much fun! ;)
Pekka
http://photography-on-the.net/