org.LatencyUtils
Class MovingAverageIntervalEstimator

java.lang.Object
  extended by org.LatencyUtils.IntervalEstimator
      extended by 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.


Field Summary
protected  java.util.concurrent.atomic.AtomicLong count
           
protected  long[] intervalEndTimes
           
protected  int windowLength
           
protected  int windowMagnitude
           
protected  int windowMask
           
 
Constructor Summary
MovingAverageIntervalEstimator(int requestedWindowLength)
           
 
Method Summary
protected  int getCurrentPosition()
           
 long getEstimatedInterval(long when)
          Provides the estimated interval
 void recordInterval(long when)
          Record an interval
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

MovingAverageIntervalEstimator

public MovingAverageIntervalEstimator(int requestedWindowLength)
Parameters:
requestedWindowLength - The requested length of the moving window. May be rounded up to nearest power of 2.
Method Detail

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()