@NotThreadSafe public class StopWatch extends Object implements IStoppable, Serializable
System.nanoTime().| Modifier | Constructor and Description |
|---|---|
protected |
StopWatch(boolean bStart)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static StopWatch |
createdStarted() |
static StopWatch |
createdStopped() |
protected long |
getCurrentNanoTime() |
Duration |
getDuration() |
long |
getMillis() |
long |
getNanos() |
long |
getSeconds() |
boolean |
isStarted() |
boolean |
isStopped() |
EChange |
reset()
Reset all saved durations, in case this stop watch is to be used in a loop.
|
void |
restart()
Stops, resets and starts the stop watch.
|
static TimeValue |
runMeasured(Runnable aRunnable)
Run the passed runnable and measure the time.
|
EChange |
start()
Start the stop watch.
|
EChange |
stop()
Stop the stop watch.
|
Duration |
stopAndGetDuration()
Stop the stop watch and get the duration since the start.
|
long |
stopAndGetMillis()
Stop the stop watch and get the elapsed milliseconds since the start.
|
long |
stopAndGetNanos()
Stop the stop watch and get the elapsed nanoseconds since the start.
|
long |
stopAndGetSeconds()
Stop the stop watch and get the elapsed seconds since the start.
|
String |
toString() |
protected StopWatch(boolean bStart)
bStart - if true the stop watch is directly started!@Nonnull public EChange reset()
EChange.protected final long getCurrentNanoTime()
@Nonnull public EChange stop()
stop in interface IStoppableEChange.CHANGED if the stop watch was previously running
and is now stopped, and EChange.UNCHANGED if the stop watch
was already stopped.public void restart()
public boolean isStarted()
true if the stop watch is currently started (running),
false otherwise.public boolean isStopped()
true if the stop watch is currently stopped (not
running), false otherwise.@Nonnegative public long getNanos()
@Nonnegative public long getMillis()
@Nonnegative public long getSeconds()
@Nonnegative public long stopAndGetNanos()
@Nonnegative public long stopAndGetMillis()
@Nonnegative public long stopAndGetSeconds()
@Nonnull public Duration stopAndGetDuration()
@Nonnull @ReturnsMutableCopy public static StopWatch createdStarted()
StopWatch object that is started. Never
null.@Nonnull @ReturnsMutableCopy public static StopWatch createdStopped()
StopWatch object that is NOT started. Never
null.Copyright © 2014–2019 Philip Helger. All rights reserved.