|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.LatencyUtils.IntervalEstimator org.LatencyUtils.MovingAverageIntervalEstimator org.LatencyUtils.TimeCappedMovingAverageIntervalEstimator
public class TimeCappedMovingAverageIntervalEstimator
A moving average interval estimator with a cap on the time window length that the moving window must completely fit in in order to provide estimated time intervals.
A time capped interval estimator is useful for conservatively estimating time intervals in environments where rates can change dramatically and semi-statically. For example, the rate of market rate updates seen just before market close can be very high, dropping dramatically at market close and staying low thereafter. A non-time-capped moving average estimator will project short estimated time interval long after market close, while a time capped interval estimator will avoid carrying the small time interval beyond the time cap.
TimeCappedMovingAverageIntervalEstimator estimates time intervals by averaging the time interval values recorded in a moving window, but if any of the results in the moving window occur outside of the capped time span requested, only the results that fall within the time cap will be considered.
TimeCappedMovingAverageIntervalEstimator can react to pauses reported by an optional PauseDetector by temporarily expanding the time cap to include each pause length, until such a time that the original time cap no longer overlaps with the pause. It will also subtract the pause length from interval times measured across a detected pause. Providing a pause detector is highly recommended, as without one the time cap can cause over-conservative interval estimation (i.e. estimated interval times that are much higher than needed) in the presence of pauses.
All times and time units are in nanoseconds
Field Summary |
---|
Fields inherited from class org.LatencyUtils.MovingAverageIntervalEstimator |
---|
count, intervalEndTimes, windowLength, windowMagnitude, windowMask |
Constructor Summary | |
---|---|
TimeCappedMovingAverageIntervalEstimator(int requestedWindowLength,
long timeCap)
|
|
TimeCappedMovingAverageIntervalEstimator(int requestedWindowLength,
long timeCap,
PauseDetector pauseDetector)
|
Method Summary | |
---|---|
long |
getEstimatedInterval(long when)
Provides the estimated interval |
void |
recordInterval(long when)
Record an interval |
void |
stop()
Stop the tracking via the pauseDetector, and remove this estimator from the pause detector's listeners. |
java.lang.String |
toString()
|
Methods inherited from class org.LatencyUtils.MovingAverageIntervalEstimator |
---|
getCurrentPosition |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TimeCappedMovingAverageIntervalEstimator(int requestedWindowLength, long timeCap)
requestedWindowLength
- The requested length of the moving window. May be rounded up to nearest
power of 2.timeCap
- The cap on time span length (in nanosecond units) in which all window results must fit
in order for average estimate to be providedpublic TimeCappedMovingAverageIntervalEstimator(int requestedWindowLength, long timeCap, PauseDetector pauseDetector)
requestedWindowLength
- The requested length of the moving window. May be rounded up to nearest
power of 2.timeCap
- The cap on time span length in which all window results must fit in order for average
estimate to be providedpauseDetector
- The PauseDetector to use to track pausesMethod Detail |
---|
public void recordInterval(long when)
IntervalEstimator
recordInterval
in class MovingAverageIntervalEstimator
when
- the end time (in nanoTime units) at which the interval was observed.public long getEstimatedInterval(long when)
IntervalEstimator
getEstimatedInterval
in class MovingAverageIntervalEstimator
when
- the time (preferably now) at which the estimated interval is requested.
public void stop()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |