public class SlidingTimeWindowMovingAverages extends Object implements MovingAverages
Meter
.
The averages are unweighted, i.e. they include strictly only the events in the
sliding time window, every event having the same weight. Unlike the
the more widely used ExponentialMovingAverages
implementation,
with this class the moving average rate drops immediately to zero if the last
marked event is older than the time window.
A Meter
with SlidingTimeWindowMovingAverages
works similarly to
a Histogram
with an SlidingTimeWindowArrayReservoir
, but as a Meter
needs to keep track only of the count of events (not the events itself), the memory
overhead is much smaller. SlidingTimeWindowMovingAverages uses buckets with just one
counter to accumulate the number of events (one bucket per seconds, giving 900 buckets
for the 15 minutes time window).
Constructor and Description |
---|
SlidingTimeWindowMovingAverages()
Creates a new
SlidingTimeWindowMovingAverages . |
SlidingTimeWindowMovingAverages(Clock clock)
Creates a new
SlidingTimeWindowMovingAverages . |
Modifier and Type | Method and Description |
---|---|
double |
getM15Rate()
Returns the fifteen-minute moving average rate
|
double |
getM1Rate()
Returns the one-minute moving average rate
|
double |
getM5Rate()
Returns the five-minute moving average rate
|
void |
tickIfNecessary()
Tick the internal clock of the MovingAverages implementation if needed
(according to the internal ticking interval)
|
void |
update(long n)
Update all three moving averages with n events having occurred since the last update.
|
public SlidingTimeWindowMovingAverages()
SlidingTimeWindowMovingAverages
.public SlidingTimeWindowMovingAverages(Clock clock)
SlidingTimeWindowMovingAverages
.clock
- the clock to use for the meter tickspublic void update(long n)
MovingAverages
update
in interface MovingAverages
public void tickIfNecessary()
MovingAverages
tickIfNecessary
in interface MovingAverages
public double getM15Rate()
MovingAverages
getM15Rate
in interface MovingAverages
public double getM5Rate()
MovingAverages
getM5Rate
in interface MovingAverages
public double getM1Rate()
MovingAverages
getM1Rate
in interface MovingAverages
Copyright © 2011. All rights reserved.