Class Timed

java.lang.Object
com.helixframework.time.Timed

public class Timed extends Object
Wrapper function that executes a function and times the execution.
  • Method Details

    • execute

      public static <T> Timed.TimedResult<T> execute(Timed.TimedFunction<T> fn) throws Exception
      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 execute
      meterRegistry - meter registry to record the execution time
      name - name of the operation
      Returns:
      result of the wrapped function
      Throws:
      Exception - if an exception occurs in the wrapped function
    • execute

      public static Timed.TimedResult<Void> execute(Timed.TimedVoidFunction fn) throws Exception
      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 execute
      meterRegistry - meter registry to record the execution time
      name - 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

      public static <T> Timed.TimedResult<T> executeNoCheck(Timed.TimedFunction<T> fn)
      Executes the wrapped function and times the execution. Checked exceptions thrown by the function are wrapped in a RuntimeException and 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 a RuntimeException and rethrown.
      Type Parameters:
      T - return type of the timed function
      Parameters:
      fn - timed function to execute
      meterRegistry - meter registry to record the execution time
      name - name of the operation
      Returns:
      a TimedResult object containing the result of the timed function and the execution time in milliseconds
    • executeNoCheck

      public static Timed.TimedResult<Void> executeNoCheck(Timed.TimedVoidFunction fn)
      Executes the wrapped void function and times the execution. Checked exceptions thrown by the function are wrapped in a RuntimeException and 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 a RuntimeException and rethrown.
      Parameters:
      fn - timed void function to execute
      meterRegistry - meter registry to record the execution time
      name - 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