Top Description Fields Constructors Methods
org.LatencyUtils

public Class MovingAverageIntervalEstimator

extends IntervalEstimator
Class Inheritance
Known Direct Subclasses
org.LatencyUtils.TimeCappedMovingAverageIntervalEstimator
Imports
java.util.concurrent.atomic.AtomicLong

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

Modifier and TypeField and Description
protected AtomicLong
protected final long[]
protected final int
protected final int
protected final int

Constructor Summary

AccessConstructor and Description
public
MovingAverageIntervalEstimator(final int
The requested length of the moving window. May be rounded up to nearest power of 2.
requestedWindowLength
)

Method Summary

Modifier and TypeMethod and Description
protected int
public long
getEstimatedInterval(long
the time (preferably now) at which the estimated interval is requested.
when
)

Implements abstract org.LatencyUtils.IntervalEstimator.getEstimatedInterval.

Provides the estimated interval
public void
recordInterval(long
the end time (in nanoTime units) at which the interval was observed.
when
)

Implements abstract org.LatencyUtils.IntervalEstimator.recordInterval.

Record an interval
pack-priv int

Field Detail

countback to summary
protected AtomicLong count
intervalEndTimesback to summary
protected final long[] intervalEndTimes
windowLengthback to summary
protected final int windowLength
windowMagnitudeback to summary
protected final int windowMagnitude
windowMaskback to summary
protected final int windowMask

Constructor Detail

MovingAverageIntervalEstimatorback to summary
public MovingAverageIntervalEstimator(final int requestedWindowLength)
Parameters
requestedWindowLength:int

The requested length of the moving window. May be rounded up to nearest power of 2.

Method Detail

getCurrentPositionback to summary
protected int getCurrentPosition()
getEstimatedIntervalback to summary
public long getEstimatedInterval(long when)

Implements abstract org.LatencyUtils.IntervalEstimator.getEstimatedInterval.

Doc from org.LatencyUtils.IntervalEstimator.getEstimatedInterval.

Provides the estimated interval

Parameters
when:long

the time (preferably now) at which the estimated interval is requested.

Returns:long

estimated interval

Annotations
@Override
recordIntervalback to summary
public void recordInterval(long when)

Implements abstract org.LatencyUtils.IntervalEstimator.recordInterval.

Doc from org.LatencyUtils.IntervalEstimator.recordInterval.

Record an interval

Parameters
when:long

the end time (in nanoTime units) at which the interval was observed.

Annotations
@Override
recordIntervalAndReturnWindowPositionback to summary
pack-priv int recordIntervalAndReturnWindowPosition(long when)