I am positive that $t is not affected.
I plugged away at this problem for a while and figured out that the problem was the original time_now() function (which was copied verbatim from the PHP docs -- albeit with a changed name).
I traced the problem back to the original microtime function:
code:
function time_now(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$sec is the amount of seconds (a whole number) $usec is the amount of time below 1 second (a decimal number)
For some reason, occationally $usec would "turn-over" (ie: 0.998, 0.999, 0.000) but $sec would not increase by one at the same time.
So, when I ran this code:
code:
$t_start = time_now(); // Start Time
func_to_time(); // Some action
$t_end = time_now(); // End Time
$t_total = $t_end - $t_start; // Total time passed
$t_start would actually be greater than $t_end .
Anyhoo, I fixed this by making my own time_now() function:
code:
function time_now(){
$time = gettimeofday();
return ((float)$time['usec']/1000000);
}
...which returns values similar to 0.32101234. My version of time_now() is good for timing up 0.999999999 seconds, which is way more than enough for the way I am benchmarking.