@Test public void testCache() { AtomicInteger snapshotCalls = new AtomicInteger(0); MockClock clock = new MockClock(); Reservoir reservoir = new ExponentiallyDecayingReservoir(); CachedHistogram histogram = new CachedHistogram(clock, reservoir, TimeUnit.SECONDS.toMillis(1), 0.50) { @Override public Snapshot getSnapshot() { snapshotCalls.getAndIncrement(); return super.getSnapshot(); } }; long value = 2; double epsilon = 0.01; histogram.update(value); assertEquals(value, histogram.getCachedValue(), epsilon); assertEquals(1, snapshotCalls.get()); assertEquals(value, histogram.getCachedValue(), epsilon); assertEquals(1, snapshotCalls.get()); clock.tick(1); assertEquals(value, histogram.getCachedValue(), epsilon); assertEquals(2, snapshotCalls.get()); }
public double getCachedValue() { return cache.getValue(); }
CachedHistogram extends Histogram { public double getCachedValue() { return cache.getValue(); } }
CachedHistogram extends Histogram { public double getCachedValue() { return cache.getValue(); } CachedHistogram(Reservoir reservoir, long timeoutMs, double quantile);   CachedHistogram(Clock clock, Reservoir reservoir, long timeoutMs, double quantile); }
CachedHistogram extends Histogram { public double getCachedValue() { return cache.getValue(); } CachedHistogram(Reservoir reservoir, long timeoutMs, double quantile);   CachedHistogram(Clock clock, Reservoir reservoir, long timeoutMs, double quantile); double getCachedValue(); }
CachedHistogram extends Histogram { public double getCachedValue() { return cache.getValue(); } CachedHistogram(Reservoir reservoir, long timeoutMs, double quantile);   CachedHistogram(Clock clock, Reservoir reservoir, long timeoutMs, double quantile); double getCachedValue();  }