_timing_start_times[$name] = explode(' ', microtime()); } function stop($name='default') { $this->_timing_cumulative_times[$name] += $this->getTime($name); } function getTime($name='default') { if (!isset($this->_timing_start_times[$name])) { return 0; } if (!isset($this->_timing_stop_times[$name])) { $stop_time = explode(' ', microtime()); } else { $stop_time = $this->_timing_stop_times[$name]; } // Do the big numbers first so the small ones aren't lost. $current = $stop_time[1] - $this->_timing_start_times[$name][1]; $current += $stop_time[0] - $this->_timing_start_times[$name][0]; return $current; } function printAll($sort_by_time=false) { $names = array_map('strlen', array_keys($this->_timing_start_times)); sort($names); $name_len = end($names); if ($sort_by_time) { arsort($this->_timing_cumulative_times, SORT_NUMERIC); } $this->_timing_cumulative_times["TOTAL"] = array_sum($this->_timing_cumulative_times); echo '
';
	    foreach ($this->_timing_cumulative_times as $name => $time) {
	        printf("\n%-{$name_len}s $this->time_format", $name, $time);
	    }
        echo '
'; } } ?>