Package org.eclipse.jetty.util.statistic
Class RateStatistic
- java.lang.Object
-
- org.eclipse.jetty.util.statistic.RateStatistic
-
public class RateStatistic extends Object
Statistics on a time sequence rate.
Calculates the rate at which the
record()method is called over the configured period, retaining also the total count and maximum rate achieved.The implementation keeps a Deque of timestamps for all records for the last time period, so this method is not suitable for large rates unless a small time period is used.
-
-
Constructor Summary
Constructors Constructor Description RateStatistic(long period, TimeUnit units)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidage(long period, TimeUnit units)Stringdump()Stringdump(TimeUnit units)longgetCount()longgetMax()longgetOldest(TimeUnit units)longgetPeriod()intgetRate()TimeUnitgetUnits()intrecord()Records a sample value.voidreset()Resets the statistics.StringtoString()
-
-
-
Constructor Detail
-
RateStatistic
public RateStatistic(long period, TimeUnit units)
-
-
Method Detail
-
getPeriod
public long getPeriod()
-
getUnits
public TimeUnit getUnits()
-
reset
public void reset()
Resets the statistics.
-
age
protected void age(long period, TimeUnit units)
-
record
public int record()
Records a sample value.- Returns:
- the number of records in the current period.
-
getRate
public int getRate()
- Returns:
- the number of records in the current period
-
getMax
public long getMax()
- Returns:
- the max number of samples per period.
-
getOldest
public long getOldest(TimeUnit units)
- Parameters:
units- the units of the return- Returns:
- the age of the oldest sample in the requested units
-
getCount
public long getCount()
- Returns:
- the number of samples recorded
-
dump
public String dump()
-
-