Performance Measurement
Posted: Fri Oct 06, 2006 9:01 am
I try to measure how long a server takes to perform a routine using following function. It does not seem right since it uses an absolute time clock instead of a "cpu clock". Comment, please. Other methods?
Code: Select all
$_start = microtime();
...
blah blah blah
...
$t = number_format(diff_microtime($_start,microtime()), 2);
echo $t;
function diff_microtime($mt_old,$mt_new) {
list($old_usec, $old_sec) = explode(' ',$mt_old);
list($new_usec, $new_sec) = explode(' ',$mt_new);
$old_mt = ((float)$old_usec + (float)$old_sec);
$new_mt = ((float)$new_usec + (float)$new_sec);
return $new_mt - $old_mt;
}