Package io.smallrye.metrics.app
Class SimpleTimerImpl
- java.lang.Object
-
- io.smallrye.metrics.app.SimpleTimerImpl
-
- All Implemented Interfaces:
org.eclipse.microprofile.metrics.Counting,org.eclipse.microprofile.metrics.Metric,org.eclipse.microprofile.metrics.SimpleTimer
public class SimpleTimerImpl extends Object implements org.eclipse.microprofile.metrics.SimpleTimer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSimpleTimerImpl.ContextA timing context.
-
Constructor Summary
Constructors Constructor Description SimpleTimerImpl()Creates a newSimpleTimerImplusing the defaultClock.SimpleTimerImpl(Clock clock)Creates a newSimpleTimerImplthat uses the givenClock.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCount()DurationgetElapsedTime()DurationgetMaxTimeDuration()DurationgetMinTimeDuration()SimpleTimerImpl.Contexttime()Returns a newSimpleTimerImpl.Context.voidtime(Runnable event)Times and records the duration of event.<T> Ttime(Callable<T> event)Times and records the duration of event.voidupdate(Duration duration)Adds a recorded duration.
-
-
-
Constructor Detail
-
SimpleTimerImpl
public SimpleTimerImpl()
Creates a newSimpleTimerImplusing the defaultClock.
-
SimpleTimerImpl
public SimpleTimerImpl(Clock clock)
Creates a newSimpleTimerImplthat uses the givenClock.- Parameters:
clock- theClockimplementation the timer should use
-
-
Method Detail
-
update
public void update(Duration duration)
Adds a recorded duration.- Specified by:
updatein interfaceorg.eclipse.microprofile.metrics.SimpleTimer- Parameters:
duration- the length of the duration
-
time
public <T> T time(Callable<T> event) throws Exception
Times and records the duration of event.- Specified by:
timein interfaceorg.eclipse.microprofile.metrics.SimpleTimer- Type Parameters:
T- the type of the value returned byevent- Parameters:
event- aCallablewhoseCallable.call()method implements a process whose duration should be timed- Returns:
- the value returned by
event - Throws:
Exception- ifeventthrows anException
-
time
public void time(Runnable event)
Times and records the duration of event.- Specified by:
timein interfaceorg.eclipse.microprofile.metrics.SimpleTimer- Parameters:
event- aRunnablewhoseRunnable.run()method implements a process whose duration should be timed
-
time
public SimpleTimerImpl.Context time()
Returns a newSimpleTimerImpl.Context.- Specified by:
timein interfaceorg.eclipse.microprofile.metrics.SimpleTimer- Returns:
- a new
SimpleTimerImpl.Context - See Also:
SimpleTimerImpl.Context
-
getCount
public long getCount()
- Specified by:
getCountin interfaceorg.eclipse.microprofile.metrics.Counting- Specified by:
getCountin interfaceorg.eclipse.microprofile.metrics.SimpleTimer
-
getElapsedTime
public Duration getElapsedTime()
- Specified by:
getElapsedTimein interfaceorg.eclipse.microprofile.metrics.SimpleTimer
-
getMaxTimeDuration
public Duration getMaxTimeDuration()
- Specified by:
getMaxTimeDurationin interfaceorg.eclipse.microprofile.metrics.SimpleTimer
-
getMinTimeDuration
public Duration getMinTimeDuration()
- Specified by:
getMinTimeDurationin interfaceorg.eclipse.microprofile.metrics.SimpleTimer
-
-