|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnl.uu.cs.treewidth.timing.Stopwatch
public class Stopwatch
A stopwatch can be used to measure intervals.
Example usage: Simple timing.
Stopwatch t = new Stopwatch(); t.start(); ... do something ... t.stop(); long millisecondsPassed = t.getTime();
Example usage: repeat something until a second has passed. (Note that this only checks the time once every iteration, so it `do something' is expensive you can significantly overshoot one second.)
Stopwatch t = new Stopwatch(); t.start(); while( t.getTime() < 1000 ) { ... do something ... } t.stop();
Example usage: Using a custom TimeSource
.
Stopwatch t = new Stopwatch( new JavaNanoTime() );
Constructor Summary | |
---|---|
Stopwatch()
Constructs a fresh Stopwatch. |
|
Stopwatch(TimeSource timeSource)
Constructs a fresh Stopwatch which will use the provided TimeSource. |
Method Summary | |
---|---|
long |
getTime()
|
void |
reset()
|
void |
start()
Start counting time. |
void |
stop()
Stop counting time. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Stopwatch()
public Stopwatch(TimeSource timeSource)
timeSource
- Method Detail |
---|
public void start()
public void stop()
public void reset()
public long getTime()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |