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 created.
|
<T> T |
record(java.util.concurrent.Callable<T> f)
Executes the callable `f` and records the time taken.
|
void |
record(long amount,
java.util.concurrent.TimeUnit unit)
Updates the statistics kept by the counter with the specified amount.
|
void |
record(java.lang.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 created.
|
hasExpired, id, measure
void record(long amount, java.util.concurrent.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.<T> T record(java.util.concurrent.Callable<T> f) throws java.lang.Exception
f
- Function to execute and measure the execution time.java.lang.Exception
void record(java.lang.Runnable f)
f
- Function to execute and measure the execution time.long count()
long totalTime()