@ThreadSafe public static interface Stopwatch.StopwatchSet extends Stopwatch.Durations
Stopwatch.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.
Modifier and Type | Method and Description |
---|---|
void |
await()
Block until all running stopwatches have been
stopped . |
void |
await(long timeout,
TimeUnit unit)
|
Stopwatch |
create()
Create a new stopwatch that records durations with this set.
|
default <T> T |
time(Callable<T> runnable)
Time the given function.
|
default <T> void |
time(int repeat,
Callable<T> runnable,
Consumer<T> cleanup)
Time the given function multiple times.
|
default void |
time(int repeat,
Runnable runnable)
Time the given function multiple times.
|
default void |
time(Runnable runnable)
Time the given function.
|
statistics
Stopwatch create()
default void time(Runnable runnable)
runnable
- the function to calldefault <T> T time(Callable<T> runnable)
runnable
- the function that is to be executed; may not be nulldefault void time(int repeat, Runnable runnable)
repeat
- the number of times to repeat the function call; must be positiverunnable
- the function to call; may not be nulldefault <T> void time(int repeat, Callable<T> runnable, Consumer<T> cleanup) throws Exception
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 nullException
- the exception thrown by the runnable functionvoid await() throws InterruptedException
stopped
. This means that if a stopwatch
is created
but never started, this method will not wait for it. Likewise, if a stopwatch
is created
and started, then this method will block until the stopwatch is stopped
(even if the same stopwatch is started multiple times).
are stopped.InterruptedException
- if the thread is interrupted before unblockingvoid await(long timeout, TimeUnit unit) throws InterruptedException
timeout
- the maximum length of time that this method should blockunit
- the unit for the timeout; may not be nullInterruptedException
- if the thread is interrupted before unblockingCopyright © 2017 JBoss by Red Hat. All rights reserved.