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 and Description |
|---|
RateStatistic(long period,
TimeUnit units) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
age(long period,
TimeUnit units) |
String |
dump() |
String |
dump(TimeUnit units) |
long |
getCount() |
long |
getMax() |
long |
getOldest(TimeUnit units) |
long |
getPeriod() |
int |
getRate() |
TimeUnit |
getUnits() |
int |
record()
Records a sample value.
|
void |
reset()
Resets the statistics.
|
String |
toString() |
public RateStatistic(long period,
TimeUnit units)
public long getPeriod()
public TimeUnit getUnits()
public void reset()
protected void age(long period,
TimeUnit units)
public int record()
public int getRate()
public long getMax()
public long getOldest(TimeUnit units)
units - the units of the returnpublic long getCount()
public String dump()
Copyright © 1995–2018 Webtide. All rights reserved.