Package io.debezium.util
Interface Stopwatch.StopwatchSet
-
- All Superinterfaces:
Stopwatch.Durations
- Enclosing class:
- Stopwatch
@ThreadSafe public static interface Stopwatch.StopwatchSet extends Stopwatch.Durations
A set of stopwatches whose durations are combined. New stopwatches can be created at any time, and whenStopwatch.stop()
will always record their duration with this set.This set is threadsafe, meaning that multiple threads can
create()
new stopwatches concurrently, and each stopwatch's duration is measured separately. Additionally, all of the other methods of this interface are also threadsafe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
await()
Block until all running stopwatches have beenstopped
.void
await(long timeout, TimeUnit unit)
Stopwatch
create()
Create a new stopwatch that records durations with this set.default void
time(int repeat, Runnable runnable)
Time the given function multiple times.default <T> void
time(int repeat, Callable<T> runnable, Consumer<T> cleanup)
Time the given function multiple times.default void
time(Runnable runnable)
Time the given function.default <T> T
time(Callable<T> runnable)
Time the given function.-
Methods inherited from interface io.debezium.util.Stopwatch.Durations
statistics
-
-
-
-
Method Detail
-
create
Stopwatch create()
Create a new stopwatch that records durations with this set.- Returns:
- the new stopwatch; never null
-
time
default void time(Runnable runnable)
Time the given function.- Parameters:
runnable
- the function to call
-
time
default <T> T time(Callable<T> runnable)
Time the given function.- Parameters:
runnable
- the function that is to be executed; may not be null- Returns:
- the result of the operation
-
time
default void time(int repeat, Runnable runnable)
Time the given function multiple times.- Parameters:
repeat
- the number of times to repeat the function call; must be positiverunnable
- the function to call; may not be null
-
time
default <T> void time(int repeat, Callable<T> runnable, Consumer<T> cleanup) throws Exception
Time the given function multiple times.- Parameters:
repeat
- the number of times to repeat the function call; must be positiverunnable
- the function that is to be executed a number of times; may not be nullcleanup
- the function that is to be called after each time call to the runnable function, and not included in the time measurements; may be null- Throws:
Exception
- the exception thrown by the runnable function
-
await
void await() throws InterruptedException
Block until all running stopwatches have beenstopped
. This means that if a stopwatch iscreated
but never started, this method will not wait for it. Likewise, if a stopwatch iscreated
and started, then this method will block until the stopwatch isstopped
(even if the same stopwatch is started multiple times). are stopped.- Throws:
InterruptedException
- if the thread is interrupted before unblocking
-
await
void await(long timeout, TimeUnit unit) throws InterruptedException
- Parameters:
timeout
- the maximum length of time that this method should blockunit
- the unit for the timeout; may not be null- Throws:
InterruptedException
- if the thread is interrupted before unblocking
-
-