Class Stopwatch

java.lang.Object
com.seeq.link.sdk.utilities.Stopwatch

public class Stopwatch extends Object
Thin wrapper class around com.google.common.base.Stopwatch to facilitate mocking.
  • Constructor Details

    • Stopwatch

      public Stopwatch()
  • Method Details

    • start

      public void start()
    • stop

      public void stop()
    • reset

      public void reset()
    • restart

      public void restart()
    • elapsed

      public long elapsed(TimeUnit timeUnit)
    • logIfSlow

      public static void logIfSlow(Action action, Supplier<String> describeAction, int thresholdInMilliseconds)
      Performs the specified action and does not return anything. If the action takes longer than the specified number of milliseconds, logs a debug message that includes the elapsed time, the describeAction string, and the threshold.
      Parameters:
      action - An action to be performed, of type Action
      describeAction - A Supplier of a string that describes the action performed
      thresholdInMilliseconds - The threshold, in milliseconds, above which the action is logged as slow
    • logIfSlow

      public static <T, E extends Exception> T logIfSlow(CheckedActionWithResult<T,E> action, Supplier<String> describeAction, int thresholdInMilliseconds) throws E
      Performs the specified action and returns the result; possibly throws a checked exception. If the action takes longer than the specified number of milliseconds, logs a debug message that includes the elapsed time, the describeAction string, and the threshold.
      Parameters:
      action - An action to be performed, of type CheckedActionWithResult
      describeAction - A Supplier of a string that describes the action performed
      thresholdInMilliseconds - The threshold, in milliseconds, above which the action is logged as slow
      Throws:
      E extends Exception