name = $name; $this->micro = 0; $this->secondsFactor = 1000000; $this->millisecondsFactor = 1000; } private $name; private $micro; private $secondsFactor; private $millisecondsFactor; public function start() { $this->micro = microtime(true); } public function stop() { $this->micro = microtime(true) - $this->micro; } public function __toString() { return ($this->name ? $this->name . ': ' : '' ) . (string)($this->micro / $this->millisecondsFactor) . " ms"; } }