Public Member Functions | |
__construct () | |
Constructor. | |
start () | |
Start the timer. | |
stop () | |
Stop the timer. | |
getStartTime () | |
Get the start time. | |
getStopTime () | |
Get the stop time. | |
getElapsedTime () | |
Get the elapsed time between start and stop. | |
Private Attributes | |
$_startAt | |
The start time measured in the number of seconds since the Unix Epoch (1970). | |
$_stopAt | |
The stop time measured in the number of seconds since the Unix Epoch (1970). |
$timer = new Benchmark(); $timer->start(); // do some stuff; $timer->stop(); echo $timer->getElapsedTime();
Definition at line 16 of file Benchmark.class.php.
Benchmark::__construct | ( | ) |
Constructor.
Set the time zone to Europe/Stockholm.
Definition at line 23 of file Benchmark.class.php.
00024 { 00025 date_default_timezone_set('Europe/Stockholm'); 00026 $this->_startAt = NULL; 00027 $this->_stopAt = NULL; 00028 }
Benchmark::getElapsedTime | ( | ) |
Get the elapsed time between start and stop.
Definition at line 76 of file Benchmark.class.php.
00077 { 00078 $totalSeconds = $this->_stopAt - $this->_startAt; 00079 $hours = floor($totalSeconds / 3600); 00080 $minutes = floor(($totalSeconds % 60) / 60); 00081 $seconds = ($totalSeconds % 3600); 00082 return str_pad($hours, 2, '0', STR_PAD_LEFT).':'.str_pad($minutes, 2, '0', STR_PAD_LEFT).':'.str_pad($seconds, 2, '0', STR_PAD_LEFT); 00083 }
Benchmark::getStartTime | ( | ) |
Get the start time.
Definition at line 56 of file Benchmark.class.php.
Benchmark::getStopTime | ( | ) |
Get the stop time.
Definition at line 66 of file Benchmark.class.php.
Benchmark::start | ( | ) |
Benchmark::stop | ( | ) |
Stop the timer.
Definition at line 45 of file Benchmark.class.php.
Benchmark::$_startAt [private] |
The start time measured in the number of seconds since the Unix Epoch (1970).
Definition at line 88 of file Benchmark.class.php.
Benchmark::$_stopAt [private] |
The stop time measured in the number of seconds since the Unix Epoch (1970).
Definition at line 93 of file Benchmark.class.php.