I implemented a timer in my PHP page to see how long it takes to run.
Here's the code:
$this->start_time = microtime();
/* All the code */
$this->end_time = microtime();
$this->calc_time = ($this->end_time - $this->start_time);
print "<tr><td colspan=\"5\">C alculated in: <b>";
printf("%." . $this->time_precisi on . "f", $this->calc_time);
print " seconds</b></td></tr>\n";
It works, but occasionally it returns a negative value, i.e. -0.890163
seconds. Why does this happen and how can I fix it?
Here's the code:
$this->start_time = microtime();
/* All the code */
$this->end_time = microtime();
$this->calc_time = ($this->end_time - $this->start_time);
print "<tr><td colspan=\"5\">C alculated in: <b>";
printf("%." . $this->time_precisi on . "f", $this->calc_time);
print " seconds</b></td></tr>\n";
It works, but occasionally it returns a negative value, i.e. -0.890163
seconds. Why does this happen and how can I fix it?
Comment