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.
|
default void |
record(Duration[] amounts,
int n)
Updates the statistics kept by the timer with the specified amounts.
|
default void |
record(long[] amounts,
int n,
TimeUnit unit)
Updates the statistics kept by the timer with the specified amounts.
|
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.default void record(long[] amounts, int n, TimeUnit unit)
amounts
- Duration of events being measured by this timer. If the amount is less than 0
for a value, the value will be dropped.n
- The number of elements to write from the amounts array (starting from 0). If n is
<= 0 no entries will be recorded. If n is greater than amounts.length, all amounts
will be recorded.unit
- Time unit for the amounts being recorded.record(long, TimeUnit)
default void record(Duration[] amounts, int n)
amounts
- Duration of events being measured by this timer. If the amount is less than 0
for a value, the value will be dropped.n
- The number of elements to write from the amounts array (starting from 0). If n is
<= 0 no entries will be recorded. If n is greater than amounts.length, all amounts
will be recorded.record(Duration)
<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()