public interface Timer extends Meter
Modifier and Type | Interface and Description |
---|---|
static class |
Timer.Builder |
Meter.Id, Meter.Type
Modifier and Type | Method and Description |
---|---|
static Timer.Builder |
builder(java.lang.String name) |
long |
count()
The number of times that record has been called since this timer was created.
|
default Meter.Type |
getType() |
default java.lang.Iterable<Measurement> |
measure()
Get a set of measurements.
|
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.
|
<T> T |
record(java.util.function.Supplier<T> f)
Executes the Supplier `f` and records the time taken.
|
<T> T |
recordCallable(java.util.concurrent.Callable<T> f)
Executes the callable `f` and records the time taken.
|
double |
totalTime(java.util.concurrent.TimeUnit unit)
The total time of all recorded events since this timer was created.
|
<T> java.util.concurrent.Callable<T> |
wrap(java.util.concurrent.Callable<T> f)
Wrap a
Callable so that it is timed when invoked. |
default java.lang.Runnable |
wrap(java.lang.Runnable f)
Wrap a
Runnable so that it is timed when invoked. |
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.function.Supplier<T> f)
f
- Function to execute and measure the execution time.<T> T recordCallable(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.default java.lang.Runnable wrap(java.lang.Runnable f)
Runnable
so that it is timed when invoked.f
- The Runnable to time when it is invoked.<T> java.util.concurrent.Callable<T> wrap(java.util.concurrent.Callable<T> f)
Callable
so that it is timed when invoked.f
- The Callable to time when it is invoked.long count()
double totalTime(java.util.concurrent.TimeUnit unit)
default java.lang.Iterable<Measurement> measure()
Meter
default Meter.Type getType()
static Timer.Builder builder(java.lang.String name)