Class StopWatch
- java.lang.Object
-
- dk.cloudcreate.essentials.shared.time.StopWatch
-
public class StopWatch extends Object
Stop watch feature that allows you to time operations
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StopWatchstart()Create a newStopWatchstatic StopWatchstart(String description)Create a newStopWatchTimingstop()Call this method to end the timing operationstatic Durationtime(Runnable operation)Time how long it takes to perform an operationstatic <R> TimingWithResult<R>time(Supplier<R> operation)Time how long it takes to perform an operation
-
-
-
Method Detail
-
time
public static Duration time(Runnable operation)
Time how long it takes to perform an operation- Parameters:
operation- the operation to perform- Returns:
- the time it took to perform the operation as a
Duration
-
time
public static <R> TimingWithResult<R> time(Supplier<R> operation)
Time how long it takes to perform an operation- Type Parameters:
R- The return type of the operation- Parameters:
operation- the operation to perform- Returns:
- the timing result (the result together with the time it took to perform the operation as a
Duration)
-
-