Package org.eclipse.microprofile.metrics
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)
.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
-
-