use of com.twitter.common.stats.WindowedStatistics in project commons by twitter.
the class WindowedStatsTest method testCleaningOfExpiredWindows.
@Test
public void testCleaningOfExpiredWindows() {
FakeClock clock = new FakeClock();
WindowedStatistics ws = new WindowedStatistics(window, slices, clock);
long n = 1000L;
for (int i = 0; i < n; i++) {
ws.accumulate(i);
}
assertEmpty(ws);
clock.advance(Amount.of(1 + sliceDuration, Time.NANOSECONDS));
ws.refresh();
// this window is not empty
assertEquals(n, ws.populationSize());
clock.advance(Amount.of(100 * sliceDuration, Time.NANOSECONDS));
ws.refresh();
// this window has been cleaned
assertEmpty(ws);
}
use of com.twitter.common.stats.WindowedStatistics in project commons by twitter.
the class WindowedStatsTest method testEmptyStats.
@Test
public void testEmptyStats() {
FakeClock clock = new FakeClock();
WindowedStatistics ws = new WindowedStatistics(window, slices, clock);
assertEmpty(ws);
}
Aggregations