Timer.Timed| Constructor and Description |
|---|
DefaultTimer(java.util.concurrent.TimeUnit timeUnit) |
| Modifier and Type | Method and Description |
|---|---|
long |
count()
The number of times
Timer.time(Duration) was called. |
void |
record(long amount,
java.util.concurrent.TimeUnit unit)
Records a custom amount in the given time unit.
|
Timer.Timed |
start()
Starts the timer and returns a
Timer.Timed instance. |
void |
time(java.lang.Runnable runnable)
Executes and measures the given
Runnable instance. |
<T> T |
time(java.util.function.Supplier<T> supplier)
Gets the result from the given
Supplier and measures its execution time. |
<T> T |
timeCallable(java.util.concurrent.Callable<T> callable)
Executes and measures the given
Callable and returns its result. |
java.lang.String |
toString() |
java.time.Duration |
totalDuration()
The total duration that was recorded.
|
java.util.concurrent.TimeUnit |
unit()
The
TimeUnit of the timer. |
public long count()
TimerTimer.time(Duration) was called.count in interface TimerTimer.time(Duration) was called.public java.time.Duration totalDuration()
TimertotalDuration in interface Timerpublic Timer.Timed start()
TimerTimer.Timed instance. Call Timer.Timed.stop() to complete
the timing.start in interface TimerTimer.Timed instance with the start time recorded.public void record(long amount,
java.util.concurrent.TimeUnit unit)
Timerpublic <T> T time(java.util.function.Supplier<T> supplier)
TimerSupplier and measures its execution time.public <T> T timeCallable(java.util.concurrent.Callable<T> callable)
throws java.lang.Exception
TimerCallable and returns its result.timeCallable in interface TimerT - The type of the Callablecallable - The Callable to execute and measure.Callable.java.lang.Exception - In case the Callable fails.public void time(java.lang.Runnable runnable)
TimerRunnable instance.public java.util.concurrent.TimeUnit unit()
TimerTimeUnit of the timer.public java.lang.String toString()
toString in class java.lang.Object