A small PHP class to measure PHP scripts execution time.
Simply initialize a MicroTimer instance to get started.
All methods return the object instance and can be chained.
<?php
$timer = new MicroTimer();
$timer->start();
// do stuff
echo $timer->stop()->getTime();
?>
<?php
// Start the timer.
$timer->start();
// Stop the timer.
$timer->stop();
// Get time (milliseconds).
$timer->getTime();
// Get time (seconds) with 3 decimals.
$timer->getTimeInSeconds(3);
// Erase and reset internal data.
$timer->reset();
?>
By design, each MicroTimer instance can only be started and stopped once, retaining all its internal data for later use.
Reuse a previously-created instance by using the reset() method.