org.LatencyUtils
Class MovingAverageIntervalEstimator
java.lang.Object
org.LatencyUtils.IntervalEstimator
org.LatencyUtils.MovingAverageIntervalEstimator
- Direct Known Subclasses:
- TimeCappedMovingAverageIntervalEstimator
public class MovingAverageIntervalEstimator
- extends IntervalEstimator
A moving average interval estimator. Estimates intervals by averaging the interval values recorded in a
moving window. Will only provide average estimate once enough intervals have been collected to fill the
window, and will return an impossibly long interval estimate until then.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
intervalEndTimes
protected final long[] intervalEndTimes
windowMagnitude
protected final int windowMagnitude
windowLength
protected final int windowLength
windowMask
protected final int windowMask
count
protected java.util.concurrent.atomic.AtomicLong count
MovingAverageIntervalEstimator
public MovingAverageIntervalEstimator(int requestedWindowLength)
- Parameters:
requestedWindowLength
- The requested length of the moving window. May be rounded up to nearest power of 2.
recordInterval
public void recordInterval(long when)
- Description copied from class:
IntervalEstimator
- Record an interval
- Specified by:
recordInterval
in class IntervalEstimator
- Parameters:
when
- the end time (in nanoTime units) at which the interval was observed.
getEstimatedInterval
public long getEstimatedInterval(long when)
- Description copied from class:
IntervalEstimator
- Provides the estimated interval
- Specified by:
getEstimatedInterval
in class IntervalEstimator
- Parameters:
when
- the time (preferably now) at which the estimated interval is requested.
- Returns:
- estimated interval
getCurrentPosition
protected int getCurrentPosition()