start(); } /** Also restart. */ function start() { $this->start = microtime(true); $this->elapsed = 0; $this->isRunning = true; } function stop() { $this->stop = microtime(true); $this->elapsed += $this->getElapsedTime(); $this->isRunning = false; return $this->getElapsedTime(); } function restartKeepElapsed() { $this->start = microtime(true); $this->isRunning = true; } /** * @return float in seconds */ function getElapsedTime() { if ($this->isRunning) { return microtime(true) - $this->start + $this->elapsed; } return $this->elapsed; } }