com.sun.labs.minion.util
Class StopWatch

java.lang.Object
  extended by com.sun.labs.minion.util.StopWatch
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
NanoWatch

public class StopWatch
extends java.lang.Object
implements java.io.Serializable

A class implementing a simple stop watch that can be used for timing.

See Also:
Serialized Form

Field Summary
protected  int clicks
          The number of starts and stops since the last reset.
protected  long lastStart
          The last start time.
protected  long lastTime
          The amount of time for the last start/stop pair.
protected  long time
          The amount of time accumulated on the timer.
 
Constructor Summary
StopWatch()
          Creates a new stop watch.
 
Method Summary
 void accumulate(StopWatch sw)
           
 double getAvgTime()
           
 int getClicks()
          Gets the number of times that the watch was started and stopped since the last reset.
 long getLastTime()
           
 long getTime()
          Gets the number of milliseconds on the timer.
 void reset()
          Resets the accumulated time.
 void start()
          Starts the timer.
 void stop()
          Stops the timer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

time

protected long time
The amount of time accumulated on the timer.


lastTime

protected long lastTime
The amount of time for the last start/stop pair.


clicks

protected int clicks
The number of starts and stops since the last reset.


lastStart

protected long lastStart
The last start time.

Constructor Detail

StopWatch

public StopWatch()
Creates a new stop watch.

Method Detail

start

public void start()
Starts the timer.


stop

public void stop()
Stops the timer.


reset

public void reset()
Resets the accumulated time.


getTime

public long getTime()
Gets the number of milliseconds on the timer.

Returns:
The number of milliseconds on the timer.

getLastTime

public long getLastTime()

getAvgTime

public double getAvgTime()

getClicks

public int getClicks()
Gets the number of times that the watch was started and stopped since the last reset.

Returns:
The number of times that the watch was started and stopped since the last reset.
See Also:
reset()

accumulate

public void accumulate(StopWatch sw)