Timer helper


1Presentation

Helper offering the possibility of timing temporal durations. It is useful, for example, to know how long it takes to execute a process.


2Usage

use \Temma\Utils\Timer as TµTimer;

// create timer
$timer = new TµTimer();
// timer started
$timer->start();
// timer stopped
$timer->stop();
// display time in seconds
print($timer->getTime());
// resume timing (without losing elapsed time)
$time->resume();
// stop and retrieve total time
$delai = $timer->stop()->getTime();

The timer can be reset at any time by calling the start() method.

The start(), stop() and resume() methods return the object instance. The getTime() method returns a decimal number corresponding to the seconds elapsed.