Class Stopwatch
- java.lang.Object
-
- org.apache.druid.java.util.common.Stopwatch
-
public class Stopwatch extends Object
Thread-safe wrapper overStopwatch.Thread safety has been limited to the start/stop methods for now as they are the only ones that can throw an exception in an illegal state and are thus vulnerable to race conditions.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StopwatchcreateStarted()static StopwatchcreateStarted(com.google.common.base.Ticker ticker)static StopwatchcreateUnstarted()booleanhasElapsed(org.joda.time.Duration duration)Checks if the given duration has already elapsed on the stopwatch.booleanhasNotElapsed(org.joda.time.Duration duration)Checks that the given duration has not elapsed on the stopwatch.booleanisRunning()longmillisElapsed()Returns the milliseconds elapsed on the stopwatch.voidreset()voidrestart()Invokesreset().start()on the underlyingStopwatch.voidstart()voidstop()
-
-
-
Method Detail
-
createStarted
public static Stopwatch createStarted()
-
createUnstarted
public static Stopwatch createUnstarted()
-
createStarted
public static Stopwatch createStarted(com.google.common.base.Ticker ticker)
-
start
public void start()
-
stop
public void stop()
-
reset
public void reset()
-
restart
public void restart()
Invokesreset().start()on the underlyingStopwatch.
-
isRunning
public boolean isRunning()
-
millisElapsed
public long millisElapsed()
Returns the milliseconds elapsed on the stopwatch.
-
hasElapsed
public boolean hasElapsed(org.joda.time.Duration duration)
Checks if the given duration has already elapsed on the stopwatch.
-
hasNotElapsed
public boolean hasNotElapsed(org.joda.time.Duration duration)
Checks that the given duration has not elapsed on the stopwatch. Calling this method is the same as!stopwatch.hasElapsed(duration).
-
-