PHP profiling with microtime(): Negative time?

Posted by Boldewyn on Stack Overflow See other posts from Stack Overflow or by Boldewyn
Published on 2010-04-09T11:58:30Z Indexed on 2010/04/09 12:03 UTC
Read the original article Hit count: 340

Filed under:
|
|

For a very simple profiling I use microtime() like this:

$now = microtime();
for (...) {
    // do something
    echo microtime() - $now;
    $now = microtime();
}

Now, the output of the echo line seems completely random, that is, I expected fluctuations, but I don't expected negative numbers showing up.

However, a typical result contains ~ 1/3 negative numbers. I confirmed this on Solaris (PHP 5.0.x) and WinVista (PHP 5.2.3).

What the heck is going on here? Have I invented accidently a time machine?

© Stack Overflow or respective owner

Related posts about php

Related posts about microtime