Package com.codahale.metrics
Class EWMA
java.lang.Object
com.codahale.metrics.EWMA
An exponentially-weighted moving average.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double
private static final int
private static final int
private boolean
private final double
private static final int
private static final double
private static final double
private static final double
private static final int
private double
private static final double
private final LongAdder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic EWMA
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
Creates a new EWMA which is equivalent to the UNIX five minute load average and which expects to be ticked every 5 seconds.double
Returns the rate in the given units of time.static EWMA
Creates a new EWMA which is equivalent to the UNIX one minute load average and which expects to be ticked every 5 seconds.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.
-
Field Details
-
INTERVAL
private static final int INTERVAL- See Also:
-
SECONDS_PER_MINUTE
private static final double SECONDS_PER_MINUTE- See Also:
-
ONE_MINUTE
private static final int ONE_MINUTE- See Also:
-
FIVE_MINUTES
private static final int FIVE_MINUTES- See Also:
-
FIFTEEN_MINUTES
private static final int FIFTEEN_MINUTES- See Also:
-
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
-
alpha
private final double alpha -
interval
private final double interval
-
-
Constructor Details
-
EWMA
Create a new EWMA with a specific smoothing constant.- Parameters:
alpha
- the smoothing constantinterval
- the expected tick intervalintervalUnit
- the time unit of the tick interval
-
-
Method Details
-
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
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
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
Returns the rate in the given units of time.- Parameters:
rateUnit
- the unit of time- Returns:
- the rate
-