Interface SimpleTimer
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
SimpleTimer.Context
A timing context.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
getCount()
Returns the current count.java.time.Duration
getElapsedTime()
Returns the total elapsed timing durations of all completed timing events that are recorded withupdate(Duration)
.java.time.Duration
getMaxTimeDuration()
Get the maximum recorded time duration of the SimpleTimer for the previously completed full minute.java.time.Duration
getMinTimeDuration()
Get the minimum recorded time duration of the SimpleTimer for the previously completed full minute.SimpleTimer.Context
time()
Returns a newSimpleTimer.Context
.void
time(java.lang.Runnable event)
Times and records the duration of event.<T> T
time(java.util.concurrent.Callable<T> event)
Times and records the duration of event.void
update(java.time.Duration duration)
Adds a recorded duration.
-
-
-
Method Detail
-
update
void update(java.time.Duration duration)
Adds a recorded duration.- Parameters:
duration
- the length of theduration
-
time
<T> T time(java.util.concurrent.Callable<T> event) throws java.lang.Exception
Times and records the duration of event.- Type Parameters:
T
- the type of the value returned byevent
- Parameters:
event
- aCallable
whoseCallable.call()
method implements a process whose duration should be timed- Returns:
- the value returned by
event
- Throws:
java.lang.Exception
- ifevent
throws anException
-
time
void time(java.lang.Runnable event)
Times and records the duration of event.- Parameters:
event
- aRunnable
whoseRunnable.run()
method implements a process whose duration should be timed
-
time
SimpleTimer.Context time()
Returns a newSimpleTimer.Context
.- Returns:
- a new
SimpleTimer.Context
- See Also:
SimpleTimer.Context
-
getElapsedTime
java.time.Duration getElapsedTime()
Returns the total elapsed timing durations of all completed timing events that are recorded withupdate(Duration)
.- Returns:
- the elapsed time
duration
-
getCount
long getCount()
Description copied from interface:Counting
Returns the current count.
-
getMaxTimeDuration
java.time.Duration getMaxTimeDuration()
Get the maximum recorded time duration of the SimpleTimer for the previously completed full minute.This represents the highest timed duration in the last completed full minute. For example if the last completed full minute recorded durations of 12 seconds, 9 seconds and 1 second the largest value is 12 seconds. If no time duration has been recorded in the last completed full minute then a null is returned. If there has only been one time duration recorded in the last completed full minute then this value will be returned by both
getMaxTimeDuration()
andgetMinTimeDuration()
- Returns:
- The maximum recorded time duration in the previously completed full minute or null if no values were recorded
-
getMinTimeDuration
java.time.Duration getMinTimeDuration()
Get the minimum recorded time duration of the SimpleTimer for the previously completed full minute.This represents the lowest timed duration in the last completed full minute. For example if the last completed full minute recorded durations of 12 seconds, 9 seconds and 1 second the lowest value is 1 second. If no time duration has been recorded in the last completed full minute then a null is returned. If there has only been one time duration recorded in the last completed full minute then this value will be returned by both
getMaxTimeDuration()
andgetMinTimeDuration()
- Returns:
- The minimum recorded time duration in the previously completed full minute or null if no values were recorded
-
-