public final class NanoWatch extends Watch
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.
Modifier and Type | Method and Description |
---|---|
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(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.
|
String |
toString()
Describes the current state of this watch.
|
elapsed, getTimeInSeconds, restart, seconds, timeInSeconds, timeMillis, timeSeconds
public NanoWatch start()
public long time()
time
in class Watch
RuntimeException
- if the watch was never started before calling
this method.public long getTime()
time()
method).public double getTimeInMillis()
getTimeInMillis
in class Watch
public long cumulativeTime()
cumulativeTime
in class Watch
public void reset()
public boolean isRunning()
public String toString()
Watch