Hey.
Anyone got a bit of code that returns the amount of mysql queries and total execution time in a given script?
I'm trying to not have to rely on mysql_stat, because my version of PHP doesn't support it.
Thanks.
Mysql Queries
Moderator: General Moderators
surely to that you'd need to time every mysql_query command?
you could make your own:
youd want to user higher precision timers but i hope you get the idea i cant think of any other way to do what you want
you could make your own:
Code: Select all
function my_mysql_query($qry,$con=false) {
$starttime=time();
$result=mysql_query($qry,$con);
$endtime=time();
$GLOBALSї'mysql_time']+=$endtime-$starttime;
return $result;
}Code: Select all
function my_mysql_query($qry,$con=false) {
$starttime=time();
$result=mysql_query($qry,$con);
$endtime=time();
$GLOBALSї'mysql_time']+=$endtime-$starttime;
return $result;
}Code: Select all
<?php
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$start = getmicrotime();
.. stuff to time
$end = getmicrotime();
$time = $end - $start;
echo "<p>time = " . round($time, 4);
?>
Last edited by McGruff on Thu Aug 11, 2005 12:03 pm, edited 1 time in total.
-
bionicdonkey
- Forum Contributor
- Posts: 132
- Joined: Fri Jan 31, 2003 2:28 am
- Location: Sydney, Australia
- Contact: