be.hogent.tarsos.util
Class StopWatch

java.lang.Object
  extended by be.hogent.tarsos.util.StopWatch

public final class StopWatch
extends java.lang.Object

StopWatch counts the ticks (ns) passed between initialization and invocation of ticksPassed.

Author:
Joren Six

Constructor Summary
StopWatch()
          Create and start the stop watch.
 
Method Summary
 java.lang.String formattedToString()
           
 long nanoTicksPassed()
           
 void start()
          Starts or restarts the watch.
 long ticksPassed()
           
 double timePassed(TimeUnit unit)
          Calculates and returns the time passed in the requested unit.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StopWatch

public StopWatch()
Create and start the stop watch.

Method Detail

ticksPassed

public long ticksPassed()
Returns:
The number of ticks passed between initialization and the call to ticksPassed. In milliseconds or 10^-3 seconds.

nanoTicksPassed

public long nanoTicksPassed()
Returns:
The number of ticks passed between initialization and the call to ticksPassed. In nanoseconds or 10^-9 seconds.

timePassed

public double timePassed(TimeUnit unit)
Calculates and returns the time passed in the requested unit.

Parameters:
unit - The requested time unit.
Returns:
The time passed in the requested unit.

start

public void start()
Starts or restarts the watch.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

formattedToString

public java.lang.String formattedToString()