public class RateStatistics extends Object
Modifier and Type | Field and Description |
---|---|
private long |
accumulatedCount
Total count recorded in buckets.
|
private long[] |
buckets
Counters are kept in buckets (circular buffer), with one bucket per
millisecond.
|
private int |
oldestIndex
Bucket index of oldest counter recorded in buckets.
|
private long |
oldestTime
Oldest time recorded in buckets.
|
private float |
scale
To convert counts/ms to desired units.
|
Constructor and Description |
---|
RateStatistics(int windowSizeMs)
Initializes a new
RateStatistics instance with a default scale
of 8000 (i.e. |
RateStatistics(int windowSizeMs,
float scale) |
Modifier and Type | Method and Description |
---|---|
private void |
eraseOld(long nowMs) |
long |
getAccumulatedCount() |
long |
getAccumulatedCount(long nowMs) |
long |
getRate() |
long |
getRate(long nowMs) |
void |
update(int count,
long nowMs) |
private long accumulatedCount
private final long[] buckets
private int oldestIndex
private long oldestTime
private final float scale
public RateStatistics(int windowSizeMs)
RateStatistics
instance with a default scale
of 8000 (i.e. if the input is in bytes, the result will be in bits per
second).windowSizeMs
- window size in ms for the rate estimationpublic RateStatistics(int windowSizeMs, float scale)
windowSizeMs
- window size in ms for the rate estimationscale
- coefficient to convert counts/ms to desired units. For
example, if counts represents bytes, use 8*1000 to go to bits/s.Copyright © 2018. All rights reserved.