Package com.seeq.link.sdk.utilities
Class Stopwatch
java.lang.Object
com.seeq.link.sdk.utilities.Stopwatch
Thin wrapper class around com.google.common.base.Stopwatch to facilitate mocking.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
static void
Performs the specified action and does not return anything.static <T,
E extends Exception>
TlogIfSlow
(CheckedActionWithResult<T, E> action, Supplier<String> describeAction, int thresholdInMilliseconds) Performs the specified action and returns the result; possibly throws a checked exception.void
reset()
void
restart()
void
start()
void
stop()
-
Constructor Details
-
Stopwatch
public Stopwatch()
-
-
Method Details
-
start
public void start() -
stop
public void stop() -
reset
public void reset() -
restart
public void restart() -
elapsed
-
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 ActiondescribeAction
- A Supplier of a string that describes the action performedthresholdInMilliseconds
- 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 EPerforms 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 CheckedActionWithResultdescribeAction
- A Supplier of a string that describes the action performedthresholdInMilliseconds
- The threshold, in milliseconds, above which the action is logged as slow- Throws:
E extends Exception
-