public class Clock
extends java.lang.Object
MetricEventsListener
callbacks.
Modifier and Type | Field and Description |
---|---|
static long |
SYSTEM_TIME_DISABLED_TIME
The value returned by all static methods in this class, viz.,
newStartTime(TimeUnit)
newStartTimeMillis()
onEndMillis(long)
onEnd(long, TimeUnit)
after calling disableSystemTimeCalls() |
Constructor and Description |
---|
Clock() |
Modifier and Type | Method and Description |
---|---|
static void |
disableSystemTimeCalls()
An optimization hook for low level benchmarks which will make any subsequent calls to
newStartTime(TimeUnit)
newStartTimeMillis()
onEndMillis(long)
onEnd(long, TimeUnit)
will start returning SYSTEM_TIME_DISABLED_TIME . |
long |
getDuration(java.util.concurrent.TimeUnit targetUnit)
Returns the duration for which this clock was running in the given timeunit.
|
long |
getDurationInMillis()
Returns the duration for which this clock was running in milliseconds.
|
long |
getStartTime(java.util.concurrent.TimeUnit targetUnit) |
long |
getStartTimeMillis() |
boolean |
isRunning() |
static long |
newStartTime(java.util.concurrent.TimeUnit timeUnit) |
static long |
newStartTimeMillis() |
static long |
onEnd(long startTime,
java.util.concurrent.TimeUnit timeUnit) |
static long |
onEndMillis(long startTimeMillis) |
long |
stop()
Stops this clock.
|
public static final long SYSTEM_TIME_DISABLED_TIME
disableSystemTimeCalls()
public long stop()
public long getStartTimeMillis()
public long getStartTime(java.util.concurrent.TimeUnit targetUnit)
public long getDurationInMillis()
java.lang.IllegalStateException
- If the clock is not yet stopped.public long getDuration(java.util.concurrent.TimeUnit targetUnit)
java.lang.IllegalStateException
- If the clock is not yet stopped.public boolean isRunning()
public static void disableSystemTimeCalls()
SYSTEM_TIME_DISABLED_TIME
. This essentially means that instead of calling
System.currentTimeMillis()
these methods will use SYSTEM_TIME_DISABLED_TIME
public static long newStartTimeMillis()
public static long newStartTime(java.util.concurrent.TimeUnit timeUnit)
public static long onEnd(long startTime, java.util.concurrent.TimeUnit timeUnit)
public static long onEndMillis(long startTimeMillis)