public interface LongTaskTimer extends Meter
Meter.Type
Modifier and Type | Method and Description |
---|---|
int |
activeTasks()
Returns the current number of tasks being executed.
|
long |
duration()
Returns the cumulative duration of all current tasks in nanoseconds.
|
long |
duration(long task)
Returns the current duration for an active task.
|
default Meter.Type |
getType() |
default void |
record(java.util.function.Consumer<java.lang.Long> f)
Executes the runnable `f` and records the time taken.
|
default void |
record(java.lang.Runnable f)
Executes the runnable `f` and records the time taken.
|
default <T> T |
record(java.util.function.Supplier<T> f)
Executes the callable `f` and records the time taken.
|
default <T> T |
recordCallable(java.util.concurrent.Callable<T> f)
Executes the callable `f` and records the time taken.
|
long |
start()
Start keeping time for a task.
|
long |
stop(long task)
Mark a given task as completed.
|
default <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
default <T> T record(java.util.function.Supplier<T> f) throws java.lang.Exception
f
- Function to execute and measure the execution time.java.lang.Exception
default void record(java.util.function.Consumer<java.lang.Long> f)
f
- Function to execute and measure the execution time with a reference to the
timer id useful for looking up current duration.default void record(java.lang.Runnable f)
f
- Function to execute and measure the execution time.long start()
long stop(long task)
task
- Id for the task to stop. This should be the value returned from start()
.long duration(long task)
task
- Id for the task to stop. This should be the value returned from start()
.long duration()
int activeTasks()
default Meter.Type getType()