Source for file Timer.class.php
Documentation is available at Timer.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* This is a digital Stopwatch of sorts. It simply will mark a start time (in
* microseconds) and a stop time (in mircoseconds). It will return the difference
* between the two as a float. It should also mark Lap times. These are time
* stamps (in mircoseconds) marked between the start and stop time.
* This will indicate the actual microtime value record at the particular Lap. If
* the value is '0' or 'null', it will return the Start Stamp (or use startTime()).
* If the value is negative, the Stop Stamp will return (or use stopTime()).
* This will indicate the time on the supplied Lap from the previous Lap. If the
* value is '0' or 'null, the total Time (from start to stop) will be returned. If
* the value is greater than the total number of laps, the difference from the stop
* time and the last lap will be given.
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* Starts the Timer by recording the current time stamp
* @precondition !isRunning()
* @postcondition isStarted()
* @param bool $reset resets timer
public function start ($reset=
false);
* Saves the Mark (or Lap)
* @precondition isRunning()
* Stops the Timer by recording the current time stamp
* @precondition isRunning()
* @postcondition isStopped()
* @postcondition !isRunning()
* @postcondition isStopped()
public function reset ();
* Returns the actual microtime value of the given lap (0 => start time)
* @param int $lap (0 returns start time, if > laps() or -1, returns stop time)
public function stamp ($lap=
null);
* Returns the time difference from the given lap to the previous lap
* If the parameter is null or 0, it will return the total time from
* start to stop recorded by the Timer.
* @precondition laps() > 2
* @param int $lap lap number (if > laps(), returns last time)
* @param int $precision rounds the number to the given precision
public function time ($lap=
null, $precision=
null);
* Returns the average time between Laps
* @precondition laps() >= 2
* @param int $precision rounds the number to the given precision
public function average ($precision=
null);
* Returns the number of Laps
* Returns if the Timer is running (or has been started)
* Returns if the Timer is stopped