Package com.codahale.metrics
Class EWMA
- java.lang.Object
-
- com.codahale.metrics.EWMA
-
public class EWMA extends java.lang.ObjectAn exponentially-weighted moving average.
-
-
Field Summary
Fields Modifier and Type Field Description private doublealphaprivate static intFIFTEEN_MINUTESprivate static intFIVE_MINUTESprivate booleaninitializedprivate doubleintervalprivate static intINTERVALprivate static doubleM1_ALPHAprivate static doubleM15_ALPHAprivate static doubleM5_ALPHAprivate static intONE_MINUTEprivate doublerateprivate static doubleSECONDS_PER_MINUTEprivate LongAdderuncounted
-
Constructor Summary
Constructors Constructor Description EWMA(double alpha, long interval, java.util.concurrent.TimeUnit intervalUnit)Create a new EWMA with a specific smoothing constant.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EWMAfifteenMinuteEWMA()Creates a new EWMA which is equivalent to the UNIX fifteen minute load average and which expects to be ticked every 5 seconds.static EWMAfiveMinuteEWMA()Creates a new EWMA which is equivalent to the UNIX five minute load average and which expects to be ticked every 5 seconds.doublegetRate(java.util.concurrent.TimeUnit rateUnit)Returns the rate in the given units of time.static EWMAoneMinuteEWMA()Creates a new EWMA which is equivalent to the UNIX one minute load average and which expects to be ticked every 5 seconds.voidtick()Mark the passage of time and decay the current rate accordingly.voidupdate(long n)Update the moving average with a new value.
-
-
-
Field Detail
-
INTERVAL
private static final int INTERVAL
- See Also:
- Constant Field Values
-
SECONDS_PER_MINUTE
private static final double SECONDS_PER_MINUTE
- See Also:
- Constant Field Values
-
ONE_MINUTE
private static final int ONE_MINUTE
- See Also:
- Constant Field Values
-
FIVE_MINUTES
private static final int FIVE_MINUTES
- See Also:
- Constant Field Values
-
FIFTEEN_MINUTES
private static final int FIFTEEN_MINUTES
- See Also:
- Constant Field Values
-
M1_ALPHA
private static final double M1_ALPHA
-
M5_ALPHA
private static final double M5_ALPHA
-
M15_ALPHA
private static final double M15_ALPHA
-
initialized
private volatile boolean initialized
-
rate
private volatile double rate
-
uncounted
private final LongAdder uncounted
-
alpha
private final double alpha
-
interval
private final double interval
-
-
Method Detail
-
oneMinuteEWMA
public 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.- Returns:
- a one-minute EWMA
-
fiveMinuteEWMA
public 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.- Returns:
- a five-minute EWMA
-
fifteenMinuteEWMA
public 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.- Returns:
- a fifteen-minute EWMA
-
update
public void update(long n)
Update the moving average with a new value.- Parameters:
n- the new value
-
tick
public void tick()
Mark the passage of time and decay the current rate accordingly.
-
getRate
public double getRate(java.util.concurrent.TimeUnit rateUnit)
Returns the rate in the given units of time.- Parameters:
rateUnit- the unit of time- Returns:
- the rate
-
-