Package com.codahale.metrics
Class Timer
- java.lang.Object
-
- com.codahale.metrics.Timer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTimer.ContextA timing context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCount()Returns the number of events which have been marked.doublegetFifteenMinuteRate()Returns the fifteen-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.doublegetFiveMinuteRate()Returns the five-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.doublegetMeanRate()Returns the mean rate at which events have occurred since the meter was created.doublegetOneMinuteRate()Returns the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.SnapshotgetSnapshot()Returns a snapshot of the values.Timer.Contexttime()Returns a newTimer.Context.<T> Ttime(java.util.concurrent.Callable<T> event)Times and records the duration of event.private voidupdate(long duration)voidupdate(long duration, java.util.concurrent.TimeUnit unit)Adds a recorded duration.
-
-
-
Method Detail
-
update
public void update(long duration, java.util.concurrent.TimeUnit unit)Adds a recorded duration.- Parameters:
duration- the length of the durationunit- the scale unit ofduration
-
time
public <T> T time(java.util.concurrent.Callable<T> event) throws java.lang.ExceptionTimes and records the duration of event.- 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:
java.lang.Exception- ifeventthrows anException
-
time
public Timer.Context time()
Returns a newTimer.Context.- Returns:
- a new
Timer.Context - See Also:
Timer.Context
-
getCount
public long getCount()
Description copied from interface:MeteredReturns the number of events which have been marked.
-
getFifteenMinuteRate
public double getFifteenMinuteRate()
Description copied from interface:MeteredReturns the fifteen-minute exponentially-weighted moving average rate at which events have occurred since the meter was created. This rate has the same exponential decay factor as the fifteen-minute load average in thetopUnix command.- Specified by:
getFifteenMinuteRatein interfaceMetered- Returns:
- the fifteen-minute exponentially-weighted moving average rate at which events have occurred since the meter was created
-
getFiveMinuteRate
public double getFiveMinuteRate()
Description copied from interface:MeteredReturns the five-minute exponentially-weighted moving average rate at which events have occurred since the meter was created. This rate has the same exponential decay factor as the five-minute load average in thetopUnix command.- Specified by:
getFiveMinuteRatein interfaceMetered- Returns:
- the five-minute exponentially-weighted moving average rate at which events have occurred since the meter was created
-
getMeanRate
public double getMeanRate()
Description copied from interface:MeteredReturns the mean rate at which events have occurred since the meter was created.- Specified by:
getMeanRatein interfaceMetered- Returns:
- the mean rate at which events have occurred since the meter was created
-
getOneMinuteRate
public double getOneMinuteRate()
Description copied from interface:MeteredReturns the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created. This rate has the same exponential decay factor as the one-minute load average in thetopUnix command.- Specified by:
getOneMinuteRatein interfaceMetered- Returns:
- the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created
-
getSnapshot
public Snapshot getSnapshot()
Description copied from interface:SamplingReturns a snapshot of the values.- Specified by:
getSnapshotin interfaceSampling- Returns:
- a snapshot of the values
-
update
private void update(long duration)
-
-