start(); } /** Also restart. */ function start() { $this->start = microtime(true); $this->elapsed = 0; $this->isRunning = true; } function stop() { $this->stop = microtime(true); $elapsedThisTime = $this->stop - $this->start; $this->elapsed += $elapsedThisTime; $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; } function getStartTime() { return $this->start; } }