@Test public void estimateIsolatedDelayTest() { long time = ticker.read(); assertEquals(0, averagingProgressTracker.estimateIsolatedDelay(time)); time = ticker.read(); assertTrue(averagingProgressTracker.openTask(time) <= CHECKER); assertEquals(0, averagingProgressTracker.estimateIsolatedDelay(time)); time = ticker.read(); assertTrue(averagingProgressTracker.openTask(time) <= CHECKER); assertTrue(averagingProgressTracker.estimateIsolatedDelay(time) < CHECKER); time = ticker.read(); assertTrue(averagingProgressTracker.openTask(time) >= CHECKER); assertEquals(CHECKER, averagingProgressTracker.estimateIsolatedDelay(time)); time = ticker.read(); assertTrue(averagingProgressTracker.openTask(time) >= CHECKER); assertEquals(CHECKER, averagingProgressTracker.estimateIsolatedDelay(time)); averagingProgressTracker.closeTask(ticker.read(), 0, 0, 0); averagingProgressTracker.closeTask(ticker.read(), 0, 0, 0); averagingProgressTracker.closeTask(ticker.read(), 0, 0, 0); assertEquals(0, averagingProgressTracker.estimateIsolatedDelay(ticker.read())); }
@Override protected long estimateIsolatedDelay(final long now) { final long open = tasksOpen(); if (open <= noDelayThreshold) { return 0L; } if (open >= tasksOpenLimit) { return defaultTicksPerTask(); } final double relativeRemainingCapacity = 1.0 - (double) open / tasksOpenLimit; final double delayCoefficient = (0.5 - relativeRemainingCapacity) / relativeRemainingCapacity; final long delay = (long) (ticksWorkedPerClosedTask(now) * delayCoefficient); return Math.min(delay, defaultTicksPerTask()); }
AveragingProgressTracker extends ProgressTracker { @Override protected long estimateIsolatedDelay(final long now) { final long open = tasksOpen(); if (open <= noDelayThreshold) { return 0L; } if (open >= tasksOpenLimit) { return defaultTicksPerTask(); } final double relativeRemainingCapacity = 1.0 - (double) open / tasksOpenLimit; final double delayCoefficient = (0.5 - relativeRemainingCapacity) / relativeRemainingCapacity; final long delay = (long) (ticksWorkedPerClosedTask(now) * delayCoefficient); return Math.min(delay, defaultTicksPerTask()); } }
AveragingProgressTracker extends ProgressTracker { @Override protected long estimateIsolatedDelay(final long now) { final long open = tasksOpen(); if (open <= noDelayThreshold) { return 0L; } if (open >= tasksOpenLimit) { return defaultTicksPerTask(); } final double relativeRemainingCapacity = 1.0 - (double) open / tasksOpenLimit; final double delayCoefficient = (0.5 - relativeRemainingCapacity) / relativeRemainingCapacity; final long delay = (long) (ticksWorkedPerClosedTask(now) * delayCoefficient); return Math.min(delay, defaultTicksPerTask()); } private  AveragingProgressTracker(final long limit, final long ticksPerTask);   AveragingProgressTracker(final long limit);   AveragingProgressTracker(final ProgressTracker oldTracker, final long limit, final long now);   AveragingProgressTracker(final AveragingProgressTracker oldTracker, final long now); }
AveragingProgressTracker extends ProgressTracker { @Override protected long estimateIsolatedDelay(final long now) { final long open = tasksOpen(); if (open <= noDelayThreshold) { return 0L; } if (open >= tasksOpenLimit) { return defaultTicksPerTask(); } final double relativeRemainingCapacity = 1.0 - (double) open / tasksOpenLimit; final double delayCoefficient = (0.5 - relativeRemainingCapacity) / relativeRemainingCapacity; final long delay = (long) (ticksWorkedPerClosedTask(now) * delayCoefficient); return Math.min(delay, defaultTicksPerTask()); } private  AveragingProgressTracker(final long limit, final long ticksPerTask);   AveragingProgressTracker(final long limit);   AveragingProgressTracker(final ProgressTracker oldTracker, final long limit, final long now);   AveragingProgressTracker(final AveragingProgressTracker oldTracker, final long now);  }
AveragingProgressTracker extends ProgressTracker { @Override protected long estimateIsolatedDelay(final long now) { final long open = tasksOpen(); if (open <= noDelayThreshold) { return 0L; } if (open >= tasksOpenLimit) { return defaultTicksPerTask(); } final double relativeRemainingCapacity = 1.0 - (double) open / tasksOpenLimit; final double delayCoefficient = (0.5 - relativeRemainingCapacity) / relativeRemainingCapacity; final long delay = (long) (ticksWorkedPerClosedTask(now) * delayCoefficient); return Math.min(delay, defaultTicksPerTask()); } private  AveragingProgressTracker(final long limit, final long ticksPerTask);   AveragingProgressTracker(final long limit);   AveragingProgressTracker(final ProgressTracker oldTracker, final long limit, final long now);   AveragingProgressTracker(final AveragingProgressTracker oldTracker, final long now);   }