Package com.helixframework.time
Class Timed
java.lang.Object
com.helixframework.time.Timed
Wrapper function that executes a function and times the execution.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunction that is timed.static classTiming result returned from the wrapped function.static interfaceVoid function that is timed. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Timed.TimedResult<T>execute(Timed.TimedFunction<T> fn) Executes the wrapped function and times the execution.static <T> Timed.TimedResult<T>execute(Timed.TimedFunction<T> fn, io.micrometer.core.instrument.MeterRegistry meterRegistry, String name) Executes the given timed function and records the execution time using the provided meter registry.static Timed.TimedResult<Void>Executes the wrapped void function and times the execution.static Timed.TimedResult<Void>execute(Timed.TimedVoidFunction fn, io.micrometer.core.instrument.MeterRegistry meterRegistry, String name) Executes the given timed void function and records the execution time using the provided meter registry.static <T> Timed.TimedResult<T>Executes the wrapped function and times the execution.static <T> Timed.TimedResult<T>executeNoCheck(Timed.TimedFunction<T> fn, io.micrometer.core.instrument.MeterRegistry meterRegistry, String name) Executes the given timed function and records the execution time using the provided meter registry.static Timed.TimedResult<Void>Executes the wrapped void function and times the execution.static Timed.TimedResult<Void>executeNoCheck(Timed.TimedVoidFunction fn, io.micrometer.core.instrument.MeterRegistry meterRegistry, String name) Executes the given timed void function and records the execution time using the provided meter registry.
-
Method Details
-
execute
Executes the wrapped function and times the execution.- Type Parameters:
T- return type of the wrapped function- Parameters:
fn- wrapped function to execute- Returns:
- result of the wrapped function
- Throws:
Exception- if an exception occurs in the wrapped function
-
execute
public static <T> Timed.TimedResult<T> execute(Timed.TimedFunction<T> fn, io.micrometer.core.instrument.MeterRegistry meterRegistry, String name) throws Exception Executes the given timed function and records the execution time using the provided meter registry.- Type Parameters:
T- return type of the timed function- Parameters:
fn- wrapped function to executemeterRegistry- meter registry to record the execution timename- name of the operation- Returns:
- result of the wrapped function
- Throws:
Exception- if an exception occurs in the wrapped function
-
execute
Executes the wrapped void function and times the execution.- Parameters:
fn- wrapped function to execute- Throws:
Exception- if an exception occurs in the wrapped function
-
execute
public static Timed.TimedResult<Void> execute(Timed.TimedVoidFunction fn, io.micrometer.core.instrument.MeterRegistry meterRegistry, String name) throws Exception Executes the given timed void function and records the execution time using the provided meter registry.- Parameters:
fn- timed void function to executemeterRegistry- meter registry to record the execution timename- name of the operation- Returns:
- a TimedResult object with a null result and the execution time in milliseconds
- Throws:
Exception- if an exception occurs in the wrapped function
-
executeNoCheck
Executes the wrapped function and times the execution. Checked exceptions thrown by the function are wrapped in aRuntimeExceptionand rethrown.- Type Parameters:
T- return type of the wrapped function- Parameters:
fn- wrapped function to execute- Returns:
- result of the wrapped function
- Throws:
RuntimeException- if an exception occurs in the wrapped function
-
executeNoCheck
public static <T> Timed.TimedResult<T> executeNoCheck(Timed.TimedFunction<T> fn, io.micrometer.core.instrument.MeterRegistry meterRegistry, String name) Executes the given timed function and records the execution time using the provided meter registry. Checked exceptions thrown by the function are wrapped in aRuntimeExceptionand rethrown.- Type Parameters:
T- return type of the timed function- Parameters:
fn- timed function to executemeterRegistry- meter registry to record the execution timename- name of the operation- Returns:
- a TimedResult object containing the result of the timed function and the execution time in milliseconds
-
executeNoCheck
Executes the wrapped void function and times the execution. Checked exceptions thrown by the function are wrapped in aRuntimeExceptionand rethrown.- Parameters:
fn- wrapped function to execute- Throws:
RuntimeException- if an exception occurs in the wrapped function
-
executeNoCheck
public static Timed.TimedResult<Void> executeNoCheck(Timed.TimedVoidFunction fn, io.micrometer.core.instrument.MeterRegistry meterRegistry, String name) Executes the given timed void function and records the execution time using the provided meter registry. Checked exceptions thrown by the function are wrapped in aRuntimeExceptionand rethrown.- Parameters:
fn- timed void function to executemeterRegistry- meter registry to record the execution timename- name of the operation- Returns:
- a TimedResult object with a null result and the execution time in milliseconds
- Throws:
RuntimeException- if an exception occurs in the wrapped function
-