public class SlidingTimeRate
extends java.lang.Object
Constructor and Description |
---|
SlidingTimeRate(TimeSource timeSource,
long size,
long precision,
java.util.concurrent.TimeUnit unit)
Creates a sliding rate whose time window is of the given size, with the given precision and time unit.
|
Modifier and Type | Method and Description |
---|---|
double |
get(long toAgo,
java.util.concurrent.TimeUnit unit)
Gets the current rate in the given time unit from the beginning of the time window to the
provided point in time ago.
|
double |
get(java.util.concurrent.TimeUnit unit)
Gets the current rate in the given time unit.
|
void |
prune()
Prunes the time window of old unused updates.
|
int |
size() |
void |
update(int delta)
Updates the rate.
|
public SlidingTimeRate(TimeSource timeSource, long size, long precision, java.util.concurrent.TimeUnit unit)
The precision defines how accurate the rate computation is, as it will be computed over window size +/- precision.
public void update(int delta)
public double get(long toAgo, java.util.concurrent.TimeUnit unit)
public double get(java.util.concurrent.TimeUnit unit)
public void prune()
public int size()
Copyright © 2009-2021 The Apache Software Foundation