public interface Timer extends Meter
count()
and totalTime()
,
but some implementations may not. In particular, the implementation from NoopRegistry
will always return 0.Modifier and Type | Method and Description |
---|---|
long |
count()
The number of times that record has been called since this timer was last reset.
|
<T> T |
record(Callable<T> f)
Executes the callable `f` and records the time taken.
|
default void |
record(Duration amount)
Updates the statistics kept by the counter with the specified amount.
|
void |
record(long amount,
TimeUnit unit)
Updates the statistics kept by the counter with the specified amount.
|
void |
record(Runnable f)
Executes the runnable `f` and records the time taken.
|
long |
totalTime()
The total time in nanoseconds of all recorded events since this timer was last reset.
|
hasExpired, id, measure
void record(long amount, TimeUnit unit)
amount
- Duration of a single event being measured by this timer. If the amount is less than 0
the value will be dropped.unit
- Time unit for the amount being recorded.default void record(Duration amount)
amount
- Duration of a single event being measured by this timer.<T> T record(Callable<T> f) throws Exception
f
- Function to execute and measure the execution time.Exception
void record(Runnable f)
f
- Function to execute and measure the execution time.long count()
long totalTime()