On 14 Jul 2004 05:13:52 -0700,
an********@yahoo.es (Justo) wrote:
How could i get the spent time from my PHP code? When you do a mysql
statement on a terminal this is shown at the end of the results, but i
can't find how to get this from PHP.
This will provide the _PHP_ execution time, but won't actually extract the MySQL
response that you mentioned. I'm curious if someone else can help on that
second, more accurate, result.
<?php
ereg("(\.[0-9]+) ([0-9]+)",microtime(),$time);
$starttime = doubleval($time[1])+doubleval($time[2]);
?>
[insert MySQL code here]
<?php
ereg("(\.[0-9]*) ([0-9]*)",microtime(),$time);
$endtime=doubleval($time[1])+doubleval($time[2]);
$runtime = number_format($endtime-$starttime,4)." Seconds";
echo "<!-- [$runtime] -->";
?>