info.jonclark.stat
Class SecondTimer

java.lang.Object
  extended by info.jonclark.stat.SecondTimer

public class SecondTimer
extends Object

Author:
Jonathan

Constructor Summary
SecondTimer()
          Does not catch "overlapping go" by default.
SecondTimer(boolean catchOverlappingGo)
           
 
Method Summary
 String getEventsPerSecond(long nEvents)
          Calculates the number of events that occured per second, on average, during the time this timer was accumulating.
 long getMilliseconds()
          Gets the number of milliseconds accumulated by this second timer so far
 double getSeconds()
          Gets the number of seconds accumulated by this SecondTimer so far
 void go()
          If the timer
 void pause()
          If the timer is currenting "going" then this stops the accumulation of time.
 void reset()
          Resets the amount of time accumulated by this timer to zero.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecondTimer

public SecondTimer()
Does not catch "overlapping go" by default. See next constructor for details.


SecondTimer

public SecondTimer(boolean catchOverlappingGo)
Parameters:
catchOverlappingGo - If true, calling go() twice without calling pause() will throw an exception
Method Detail

getEventsPerSecond

public String getEventsPerSecond(long nEvents)
Calculates the number of events that occured per second, on average, during the time this timer was accumulating.

Parameters:
nEvents - The number of events that occurred while this SecondTimer has been accumulating time.
Returns:

getSeconds

public double getSeconds()
Gets the number of seconds accumulated by this SecondTimer so far

Returns:

getMilliseconds

public long getMilliseconds()
Gets the number of milliseconds accumulated by this second timer so far

Returns:

go

public void go()
If the timer

Throws:
RuntimeException - if catchOverlappingGo was set to true and this is the second call to go() without a previous call to pause()

pause

public void pause()
If the timer is currenting "going" then this stops the accumulation of time. Otherwise, it has no effect.


reset

public void reset()
Resets the amount of time accumulated by this timer to zero.