|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.jinx.time.StopWatch
public class StopWatch
StopWatch allows you to determine how much time has passed in a given period
of time, using the most precise clock available. For Java 1.5 or greater,
this will use the nanosecond timer. For Java 1.4 or lower, this will use the
millisecond timer. For the official Sun JVM on 1.4+, this will use the
sun.misc.Perf class (performance profiling class) as a nanosecond timer.
You also have the option of constructing your own time source to plug
into a StopWatch.
API Stability: Stable.
Constructor Summary | |
---|---|
StopWatch()
Constructs a real-time StopWatch with one of the default time sources; the most precise time source available is used. |
|
StopWatch(boolean useNano)
Constructor that allows choosing whether or not nanosecond timing is used if available. |
|
StopWatch(TimeSource source)
Constructor for using a custom time source. |
Method Summary | |
---|---|
TimeSource |
getSource()
Provides the TimeSource for this StopWatch. |
boolean |
isNano()
Determines whether or not this StopWatch is backed by a nanosecond timer or a millisecond timer. |
boolean |
isRealTime()
Returns true if this StopWatch is backed by a real-time source. |
static void |
main(java.lang.String[] args)
Main entry point for the StopWatch test program. |
long |
millisPassed()
Provides the number of milliseconds that have passed since the last call to reset(). |
long |
nanoPassed()
Provides the number of nanoseconds that have passed since the last call to reset(). |
void |
pause()
Pauses this StopWatch. |
void |
reset()
Resets this StopWatch. |
void |
resume()
Resumes this StopWatch. |
double |
timePassed()
Provides the amount of time that has passed since the last call to reset(). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StopWatch()
public StopWatch(TimeSource source)
source
- the TimeSource that will drive this StopWatch.
java.lang.NullPointerException
- if source is null.
java.lang.IllegalArgumentException
- if source doesn't implement either of
NanoTimeSource or MillisTimeSource.public StopWatch(boolean useNano)
useNano
- if true and a nanosecond timer is available, it will be
used. Otherwise, the millisecond timer will be used.Method Detail |
---|
public TimeSource getSource()
public void reset()
public void pause()
public void resume()
public double timePassed()
public long millisPassed()
public long nanoPassed()
public boolean isRealTime()
public boolean isNano()
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |