org.apache.solr.util.stats
Class Timer

java.lang.Object
  extended by org.apache.solr.util.stats.Timer

public class Timer
extends Object

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


Constructor Summary
Timer()
           
Timer(TimeUnit durationUnit, TimeUnit rateUnit, Clock clock)
          Creates a new Timer.
 
Method Summary
 void clear()
          Clears all recorded durations.
 long getCount()
           
 TimeUnit getDurationUnit()
          Returns the timer's duration scale unit.
 String getEventType()
           
 double getFifteenMinuteRate()
           
 double getFiveMinuteRate()
           
 double getMax()
          Returns the longest recorded duration.
 double getMean()
          Returns the arithmetic mean of all recorded durations.
 double getMeanRate()
           
 double getMin()
          Returns the shortest recorded duration.
 double getOneMinuteRate()
           
 TimeUnit getRateUnit()
           
 Snapshot getSnapshot()
           
 double getStdDev()
          Returns the standard deviation of all recorded durations.
 double getSum()
          Returns the sum of all recorded durations.
 TimerContext time()
          Returns a timing TimerContext, which measures an elapsed time in nanoseconds.
<T> T
time(Callable<T> event)
          Times and records the duration of event.
 void update(long duration, TimeUnit unit)
          Adds a recorded duration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timer

public Timer()

Timer

public Timer(TimeUnit durationUnit,
             TimeUnit rateUnit,
             Clock clock)
Creates a new Timer.

Parameters:
durationUnit - the scale unit for this timer's duration metrics
rateUnit - the scale unit for this timer's rate metrics
clock - the clock used to calculate duration
Method Detail

getDurationUnit

public TimeUnit getDurationUnit()
Returns the timer's duration scale unit.

Returns:
the timer's duration scale unit

getRateUnit

public TimeUnit getRateUnit()

clear

public void clear()
Clears all recorded durations.


update

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

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

time

public <T> T time(Callable<T> event)
       throws 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:
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

getCount

public long getCount()

getFifteenMinuteRate

public double getFifteenMinuteRate()

getFiveMinuteRate

public double getFiveMinuteRate()

getMeanRate

public double getMeanRate()

getOneMinuteRate

public double getOneMinuteRate()

getMax

public double getMax()
Returns the longest recorded duration.

Returns:
the longest recorded duration

getMin

public double getMin()
Returns the shortest recorded duration.

Returns:
the shortest recorded duration

getMean

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

Returns:
the arithmetic mean of all recorded durations

getStdDev

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

Returns:
the standard deviation of all recorded durations

getSum

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

Returns:
the sum of all recorded durations

getSnapshot

public Snapshot getSnapshot()

getEventType

public String getEventType()


Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.