Gumbo_Interface_Timer



Timer Interface

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.

STAMP 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()).

TIME 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.

Author(s): Michael Luster <mluster79@yahoo.com>
License:New BSD License
Copyright:Copyright (c) 2007, iBayou, Michael Luster
Link:http://sourceforge.net/projects/phpgumbo
Version:0.0.1

Interface Methods

public num average ( [int $precision] ) [line 109]

Returns the average time between Laps

Parameter(s):

  • (int) $precision :: rounds the number to the given precision
  • precondition:  laps() >= 2

[ Top ]
public bool isRunning ( ) [line 133]

Returns if the Timer is running (or has been started)


[ Top ]
public bool isStopped ( ) [line 139]

Returns if the Timer is stopped


[ Top ]
public void lap ( ) [line 64]

Saves the Mark (or Lap)

  • precondition:  isRunning()

[ Top ]
public int laps ( ) [line 115]

Returns the number of Laps


[ Top ]
public void reset ( ) [line 78]

Resets the Timer

  • postcondition:  isStopped()
  • postcondition:  !isRunning()

[ Top ]
public num stamp ( [int $lap] ) [line 88]

Returns the actual microtime value of the given lap (0 => start time)

Parameter(s):

  • (int) $lap :: (0 returns start time, if > laps() or -1, returns stop time)

[ Top ]
public void start ( [bool $reset] ) [line 58]

Starts the Timer by recording the current time stamp

Parameter(s):

  • (bool) $reset :: resets timer
  • precondition:  !isRunning()
  • postcondition:  isStarted()

[ Top ]
public num startTime ( ) [line 121]

Returns the start time


[ Top ]
public void stop ( ) [line 71]

Stops the Timer by recording the current time stamp

  • precondition:  isRunning()
  • postcondition:  isStopped()

[ Top ]
public num stopTime ( ) [line 127]

Returns the stop time


[ Top ]
public num time ( [int $lap], [int $precision] ) [line 101]

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.

Parameter(s):

  • (int) $lap :: lap number (if > laps(), returns last time)
  • (int) $precision :: rounds the number to the given precision
  • precondition:  laps() > 2

[ Top ]