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 | Interface and Description |
|---|---|
static interface |
Timer.BatchUpdater
See
batchUpdater(int). |
| Modifier and Type | Method and Description |
|---|---|
default Timer.BatchUpdater |
batchUpdater(int batchSize)
Returns a helper that can be used to more efficiently update the timer within a
single thread.
|
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 timer 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 timer 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, measurevoid 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.Exceptionvoid record(Runnable f)
f - Function to execute and measure the execution time.long count()
long totalTime()
default Timer.BatchUpdater batchUpdater(int batchSize)
batchSize - Number of updates to batch before forcing a flush to the meter.