markers = array(); } public function start() { $this->setMarker('Start'); } public function stop() { $this->setMarker('Stop'); } public function setMarker($name) { $this->markers[$name] = $this->_getMicrotime(); } public function _getMicrotime() { $microtime = explode(' ', microtime()); return $microtime[1].substr($microtime[0], 1); } public function timeElapsed($start = 'Start', $end = 'Stop') { if ($end == 'Stop' && !isset($this->markers['Stop'])) { $this->markers['Stop'] = $this->_getMicrotime(); } if (extension_loaded('bcmath')) { return bcsub($this->markers[$end], $this->markers[$start], 6); } else { return $this->markers[$end] - $this->markers[$start]; } } public function display() { print $this->timeElapsed(); } } ?>