Package com.codahale.metrics
Class Timer
java.lang.Object
com.codahale.metrics.Timer
A timer metric which aggregates timing durations and provides duration statistics, plus
throughput statistics via
Meter
.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
getCount()
Returns the number of events which have been marked.double
Returns the fifteen-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.double
Returns the five-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.double
Returns the mean rate at which events have occurred since the meter was created.double
Returns the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.Returns a snapshot of the values.time()
Returns a newTimer.Context
.<T> T
Times and records the duration of event.private void
update
(long duration) void
Adds a recorded duration.
-
Field Details
-
meter
-
histogram
-
clock
-
-
Constructor Details
-
Method Details
-
update
Adds a recorded duration.- Parameters:
duration
- the length of the durationunit
- the scale unit ofduration
-
time
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:
Exception
- ifevent
throws anException
-
time
Returns a newTimer.Context
.- Returns:
- a new
Timer.Context
- See Also:
-
getCount
public long getCount()Description copied from interface:Metered
Returns the number of events which have been marked. -
getFifteenMinuteRate
public double getFifteenMinuteRate()Description copied from interface:Metered
Returns 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 thetop
Unix command.- Specified by:
getFifteenMinuteRate
in 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:Metered
Returns 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 thetop
Unix command.- Specified by:
getFiveMinuteRate
in 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:Metered
Returns the mean rate at which events have occurred since the meter was created.- Specified by:
getMeanRate
in interfaceMetered
- Returns:
- the mean rate at which events have occurred since the meter was created
-
getOneMinuteRate
public double getOneMinuteRate()Description copied from interface:Metered
Returns 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 thetop
Unix command.- Specified by:
getOneMinuteRate
in interfaceMetered
- Returns:
- the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created
-
getSnapshot
Description copied from interface:Sampling
Returns a snapshot of the values.- Specified by:
getSnapshot
in interfaceSampling
- Returns:
- a snapshot of the values
-
update
private void update(long duration)
-