public class EWMA
extends java.lang.Object
Taken from codahale metric module, changed to use LongAdder
Constructor and Description |
---|
EWMA(double alpha,
long interval,
java.util.concurrent.TimeUnit intervalUnit)
Create a new EWMA with a specific smoothing constant.
|
Modifier and Type | Method and Description |
---|---|
static EWMA |
fifteenMinuteEWMA()
Creates a new EWMA which is equivalent to the UNIX fifteen minute load average and which expects to be ticked
every 5 seconds.
|
static EWMA |
fiveMinuteEWMA()
Creates a new EWMA which is equivalent to the UNIX five minute load average and which expects to be ticked every
5 seconds.
|
static EWMA |
oneMinuteEWMA()
Creates a new EWMA which is equivalent to the UNIX one minute load average and which expects to be ticked every
5 seconds.
|
double |
rate(java.util.concurrent.TimeUnit rateUnit)
Returns the rate in the given units of time.
|
void |
tick()
Mark the passage of time and decay the current rate accordingly.
|
void |
update(long n)
Update the moving average with a new value.
|
public EWMA(double alpha, long interval, java.util.concurrent.TimeUnit intervalUnit)
alpha
- the smoothing constantinterval
- the expected tick intervalintervalUnit
- the time unit of the tick intervalpublic static EWMA oneMinuteEWMA()
public static EWMA fiveMinuteEWMA()
public static EWMA fifteenMinuteEWMA()
public void update(long n)
n
- the new valuepublic void tick()
public double rate(java.util.concurrent.TimeUnit rateUnit)
rateUnit
- the unit of time