Which is more accurate xhprof or microtime

119 Views Asked by At

I'm trying to measure execution time of a function.

I tried the following code snippet

$duration = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
$hours = (int)($duration/60/60);
$minutes = (int)($duration/60)-$hours*60;
$execution_time = $duration - $hours*60*60 - $minutes*60;

And I get 2sec per request

But when I use xhprof, I get 0.9 per request.

Which should I trust and why is there a second difference per request?

Thanks in advance.

0

There are 0 best solutions below