net.aavalla.utils.general
Class Timer

java.lang.Object
  extended by net.aavalla.utils.general.Timer

public final class Timer
extends java.lang.Object

This class can be used to time operations.

Author:
Lari Natri

Constructor Summary
Timer()
          Default constructor
 
Method Summary
 long getExecutionTime()
          Returns the time in nanoseconds spent after this timer has started, not counting the time it's been paused.
 double getExecutionTimeInSeconds()
          Returns the time in nanoseconds spent after this timer has started, not counting the time it's been paused.
 long getPausedTime()
          Returns the time this timer has spent in paused state.
 double getPausedTimeInSeconds()
          Returns the time this timer has spent in paused state.
 boolean isPaused()
          Returns true, if the timer is currently paused.
 boolean isStarted()
          Returns true, if the timer is running (even if it is paused).
 void pause()
          Pauses the timer.
 void start()
          Resets all aspects of the timer and (re)starts it.
 void stop()
          Stops the timer.
 void unPause()
          Unpauses the timer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timer

public Timer()
Default constructor

Method Detail

start

public final void start()
Resets all aspects of the timer and (re)starts it.


stop

public final void stop()
Stops the timer.


pause

public final void pause()
Pauses the timer. If timer isn't started yet, it will be started and immediately put to paused state.


unPause

public final void unPause()
Unpauses the timer. If timer isn't started yet, this will also start it.


getExecutionTime

public final long getExecutionTime()
Returns the time in nanoseconds spent after this timer has started, not counting the time it's been paused.

Returns:
current non-paused execution time, in nanoseconds

getExecutionTimeInSeconds

public final double getExecutionTimeInSeconds()
Returns the time in nanoseconds spent after this timer has started, not counting the time it's been paused.

Returns:
current non-paused execution time, in seconds

getPausedTime

public final long getPausedTime()
Returns the time this timer has spent in paused state. Returns 0, if timer hasn't been started yet.

Returns:
time spent in paused mode, in nanoseconds

getPausedTimeInSeconds

public final double getPausedTimeInSeconds()
Returns the time this timer has spent in paused state. Returns 0, if timer hasn't been started yet.

Returns:
time spent in paused mode, in seconds

isStarted

public final boolean isStarted()
Returns true, if the timer is running (even if it is paused).


isPaused

public final boolean isPaused()
Returns true, if the timer is currently paused. Returns false, if the timer hasn't been started yet.

Returns:
paused-state of the timer