Featured post
How to get the execution time of a MySQL query from PHP? -
this question has answer here:
- mysql execution time 3 answers
i execute mysql queries php , know how time consuming are. there way execution time of mysql query php?
i wonder if execution time depends on how loaded web server. can imagine query take more time execute if server busy other queries. on other hand, can imagine that, if server busy, query wait turn , executed (without queries executed in parallel) , waiting time not included execution time. so, scenarios (out of two) correct?
there way via mysql, however, easy (and reliable) way using php's microtime
function, returns current time milliseconds.
microtime() returns current unix timestamp microseconds. function > available on operating systems support gettimeofday() system call.
getasfloat - when called without optional argument, function returns string "msec sec" sec current time measured in number of seconds since unix epoch (0:00:00 january 1, 1970 gmt), , msec microseconds part. both portions of string returned in units of seconds.
if optional get_as_float set true float (in seconds) returned.
some example code:
$sql = '...'; $msc = microtime(true); mysql_query($sql); $msc = microtime(true)-$msc; echo $msc . ' s'; // in seconds echo ($msc * 1000) . ' ms'; // in millseconds
- Get link
- X
- Other Apps
Comments
Post a Comment