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()
Timer
Timer.time(Duration)
was called.count
in interface Timer
Timer.time(Duration)
was called.public java.time.Duration totalDuration()
Timer
totalDuration
in interface Timer
public Timer.Timed start()
Timer
Timer.Timed
instance. Call Timer.Timed.stop()
to complete
the timing.start
in interface Timer
Timer.Timed
instance with the start time recorded.public void record(long amount, java.util.concurrent.TimeUnit unit)
Timer
public <T> T time(java.util.function.Supplier<T> supplier)
Timer
Supplier
and measures its execution time.public <T> T timeCallable(java.util.concurrent.Callable<T> callable) throws java.lang.Exception
Timer
Callable
and returns its result.timeCallable
in interface Timer
T
- The type of the Callable
callable
- The Callable
to execute and measure.Callable
.java.lang.Exception
- In case the Callable
fails.public void time(java.lang.Runnable runnable)
Timer
Runnable
instance.public java.util.concurrent.TimeUnit unit()
Timer
TimeUnit
of the timer.public java.lang.String toString()
toString
in class java.lang.Object