source: trunk/lib/ScriptTimer.inc.php @ 71

Last change on this file since 71 was 42, checked in by scdev, 19 years ago

detabbed all files ;P

File size: 1.1 KB
RevLine 
[1]1<?php
2/**
[42]3 * ScriptTimer.inc.php
[1]4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
5 */
[42]6
[1]7class ScriptTimer {
8
9    var $time_format = '%.10f';
10    var $_timing_start_times;
11    var $_timing_stop_times;
[42]12
[1]13    function start($name='default')
14    {
15        $this->_timing_start_times[$name] = explode(' ', microtime());
16    }
[42]17
[1]18    function stop($name='default')
19    {
20        $this->_timing_stop_times[$name] = explode(' ', microtime());
21    }
[42]22
[1]23    function getTime($name='default')
24    {
25        if (!isset($this->_timing_start_times[$name])) {
26            return 0;
27        }
[42]28
[1]29        if (!isset($this->_timing_stop_times[$name])) {
30            $stop_time = explode(' ', microtime());
31        } else {
32            $stop_time = $this->_timing_stop_times[$name];
33        }
[42]34
[1]35        // Do the big numbers first so the small ones aren't lost.
36        $current = $stop_time[1] - $this->_timing_start_times[$name][1];
37        $current += $stop_time[0] - $this->_timing_start_times[$name][0];
[42]38
[1]39        return sprintf($this->time_format, $current);
40    }
41}
42
43?>
Note: See TracBrowser for help on using the repository browser.