use of io.airlift.testing.TestingTicker in project airlift by airlift.
the class TestQuantileDigest method testDecayedCountsWithClockIncrementSmallerThanRescaleThreshold.
@Test
public void testDecayedCountsWithClockIncrementSmallerThanRescaleThreshold() throws Exception {
int targetAgeInSeconds = (int) (QuantileDigest.RESCALE_THRESHOLD_SECONDS - 1);
TestingTicker ticker = new TestingTicker();
QuantileDigest digest = new QuantileDigest(1, ExponentialDecay.computeAlpha(0.5, targetAgeInSeconds), ticker);
addAll(digest, asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
ticker.increment(targetAgeInSeconds, TimeUnit.SECONDS);
addAll(digest, asList(10, 11, 12, 13, 14, 15, 16, 17, 18, 19));
assertEquals(digest.getCount(), 15.0);
}
use of io.airlift.testing.TestingTicker in project airlift by airlift.
the class TestQuantileDigest method testDecayedCounts.
@Test
public void testDecayedCounts() throws Exception {
TestingTicker ticker = new TestingTicker();
QuantileDigest digest = new QuantileDigest(1, ExponentialDecay.computeAlpha(0.5, 60), ticker);
addAll(digest, asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
// should have no compressions with so few values and the allowed error
assertEquals(digest.getConfidenceFactor(), 0.0);
ticker.increment(60, TimeUnit.SECONDS);
addAll(digest, asList(10, 11, 12, 13, 14, 15, 16, 17, 18, 19));
assertEquals(digest.getCount(), 15.0);
}
Aggregations