|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfc.util.Watch
fc.util.NanoWatch
public final class NanoWatch
Allows measuring the start and stop time and (hence the elapsed time) of
some event. ("event" meaning something of interest, for example, a method
call). Can be started/stopped repeatedly. (cumulative time across all such
start/stops are available via the cumulativeTime()
method).
All times are in nano-seconds.
Thread Safety: This class is not threadsafe and it's method do not acquire any locks to reduce any time skew due to lock acquisition. Multiple threads should use separate NanoWatch objects or alternatively, higher level synchronization.
A lower precision (milliseconds) watch.
Constructor Summary | |
---|---|
NanoWatch()
|
|
NanoWatch(java.lang.String name)
|
Method Summary | |
---|---|
long |
cumulativeTime()
Returns the total time recorded by this Watch (across several starts/stops) |
long |
getTime()
Returns the time elapsed since the Watch was started. |
double |
getTimeInMillis()
Returns the elapsed time in milliseconds. |
boolean |
isRunning()
Is the Watch currently running ? |
static void |
main(java.lang.String[] args)
|
void |
reset()
Reset all values to zero. |
NanoWatch |
start()
Start measuring time. |
void |
stop()
Stop measuring the time |
long |
time()
Returns the time elapsed since the Watch was started. |
java.lang.String |
toString()
Describes the current state of this watch. |
Methods inherited from class fc.util.Watch |
---|
elapsed, getTimeInSeconds, restart, seconds, timeInSeconds, timeMillis, timeSeconds |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NanoWatch(java.lang.String name)
public NanoWatch()
Method Detail |
---|
public NanoWatch start()
start
in class Watch
public void stop()
stop
in class Watch
public long time()
time
in class Watch
java.lang.RuntimeException
- if the watch was never started before calling
this method.public long getTime()
time()
method).
getTime
in class Watch
public double getTimeInMillis()
getTimeInMillis
in class Watch
public long cumulativeTime()
cumulativeTime
in class Watch
public void reset()
reset
in class Watch
public boolean isRunning()
isRunning
in class Watch
public java.lang.String toString()
Watch
toString
in class Watch
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |