com.espertech.esper.metrics.codahale_metrics.metrics.core
Class Timer

java.lang.Object
  extended by com.espertech.esper.metrics.codahale_metrics.metrics.core.Timer
All Implemented Interfaces:
Metered, Metric, Sampling, Stoppable, Summarizable

public class Timer
extends java.lang.Object
implements Metered, Stoppable, Sampling, Summarizable

A timer metric which aggregates timing durations and provides duration statistics, plus throughput statistics via Meter.


Method Summary
 void clear()
          Clears all recorded durations.
 long count()
          Returns the number of events which have been marked.
 java.util.concurrent.TimeUnit durationUnit()
          Returns the timer's duration scale unit.
 java.lang.String eventType()
          Returns the type of events the meter is measuring.
 double fifteenMinuteRate()
          Returns the fifteen-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.
 double fiveMinuteRate()
          Returns the five-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.
 Snapshot getSnapshot()
          Returns a snapshot of the values.
 double max()
          Returns the longest recorded duration.
 double mean()
          Returns the arithmetic mean of all recorded durations.
 double meanRate()
          Returns the mean rate at which events have occurred since the meter was created.
 double min()
          Returns the shortest recorded duration.
 double oneMinuteRate()
          Returns the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.
<T> void
processWith(MetricProcessor<T> processor, MetricName name, T context)
          Allow the given MetricProcessor to process this as a metric.
 java.util.concurrent.TimeUnit rateUnit()
          Returns the meter's rate unit.
 double stdDev()
          Returns the standard deviation of all recorded durations.
 void stop()
          Stop the instance.
 double sum()
          Returns the sum of all recorded durations.
 TimerContext time()
          Returns a timing TimerContext, which measures an elapsed time in nanoseconds.
<T> T
time(java.util.concurrent.Callable<T> event)
          Times and records the duration of event.
 void update(long duration, java.util.concurrent.TimeUnit unit)
          Adds a recorded duration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

durationUnit

public java.util.concurrent.TimeUnit durationUnit()
Returns the timer's duration scale unit.

Returns:
the timer's duration scale unit

rateUnit

public java.util.concurrent.TimeUnit rateUnit()
Description copied from interface: Metered
Returns the meter's rate unit.

Specified by:
rateUnit in interface Metered
Returns:
the meter's rate unit

clear

public void clear()
Clears all recorded durations.


update

public void update(long duration,
                   java.util.concurrent.TimeUnit unit)
Adds a recorded duration.

Parameters:
duration - the length of the duration
unit - the scale unit of duration

time

public <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 by event
Parameters:
event - a Callable whose Callable.call() method implements a process whose duration should be timed
Returns:
the value returned by event
Throws:
java.lang.Exception - if event throws an Exception

time

public TimerContext time()
Returns a timing TimerContext, which measures an elapsed time in nanoseconds.

Returns:
a new TimerContext

count

public long count()
Description copied from interface: Metered
Returns the number of events which have been marked.

Specified by:
count in interface Metered
Returns:
the number of events which have been marked

fifteenMinuteRate

public double fifteenMinuteRate()
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 the top Unix command.

Specified by:
fifteenMinuteRate in interface Metered
Returns:
the fifteen-minute exponentially-weighted moving average rate at which events have occurred since the meter was created

fiveMinuteRate

public double fiveMinuteRate()
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 the top Unix command.

Specified by:
fiveMinuteRate in interface Metered
Returns:
the five-minute exponentially-weighted moving average rate at which events have occurred since the meter was created

meanRate

public double meanRate()
Description copied from interface: Metered
Returns the mean rate at which events have occurred since the meter was created.

Specified by:
meanRate in interface Metered
Returns:
the mean rate at which events have occurred since the meter was created

oneMinuteRate

public double oneMinuteRate()
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 the top Unix command.

Specified by:
oneMinuteRate in interface Metered
Returns:
the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created

max

public double max()
Returns the longest recorded duration.

Specified by:
max in interface Summarizable
Returns:
the longest recorded duration

min

public double min()
Returns the shortest recorded duration.

Specified by:
min in interface Summarizable
Returns:
the shortest recorded duration

mean

public double mean()
Returns the arithmetic mean of all recorded durations.

Specified by:
mean in interface Summarizable
Returns:
the arithmetic mean of all recorded durations

stdDev

public double stdDev()
Returns the standard deviation of all recorded durations.

Specified by:
stdDev in interface Summarizable
Returns:
the standard deviation of all recorded durations

sum

public double sum()
Returns the sum of all recorded durations.

Specified by:
sum in interface Summarizable
Returns:
the sum of all recorded durations

getSnapshot

public Snapshot getSnapshot()
Description copied from interface: Sampling
Returns a snapshot of the values.

Specified by:
getSnapshot in interface Sampling
Returns:
a snapshot of the values

eventType

public java.lang.String eventType()
Description copied from interface: Metered
Returns the type of events the meter is measuring.

Specified by:
eventType in interface Metered
Returns:
the meter's event type

stop

public void stop()
Description copied from interface: Stoppable
Stop the instance.

Specified by:
stop in interface Stoppable

processWith

public <T> void processWith(MetricProcessor<T> processor,
                            MetricName name,
                            T context)
                 throws java.lang.Exception
Description copied from interface: Metric
Allow the given MetricProcessor to process this as a metric.

Specified by:
processWith in interface Metric
Type Parameters:
T - the type of the context object
Parameters:
processor - a MetricProcessor
name - the name of the current metric
context - a given context which should be passed on to processor
Throws:
java.lang.Exception - if something goes wrong

© 2006-2015 EsperTech Inc.
All rights reserved.
Visit us at espertech.com