@Test public void testRollingStats() throws Exception { RollingStats underTest = new RollingStats(2_000, MILLISECONDS); underTest.mark(); assertThat(underTest.sum(), is(1)); underTest.mark(); assertThat(underTest.sum(), is(2)); underTest.mark(); assertThat(underTest.sum(), is(3)); underTest.mark(); assertThat(underTest.sum(), is(4)); Thread.sleep(500); underTest.mark(); assertThat(underTest.sum(), is(5)); underTest.mark(); assertThat(underTest.sum(), is(6)); underTest.mark(); assertThat(underTest.sum(), is(7)); underTest.mark(); assertThat(underTest.sum(), is(8)); Thread.sleep(500); underTest.mark(); assertThat(underTest.sum(), is(9)); underTest.mark(); assertThat(underTest.sum(), is(10)); underTest.mark(); assertThat(underTest.sum(), is(11)); underTest.mark(); assertThat(underTest.sum(), is(12)); Thread.sleep(500); assertThat(underTest.sum(), is(12)); Thread.sleep(750); assertThat(underTest.sum(), is(8)); Thread.sleep(500); assertThat(underTest.sum(), is(4)); Thread.sleep(500); assertThat(underTest.sum(), is(0)); }
public RollingStats(final int size, final TimeUnit tickUnit) { this.buckets = new AtomicIntegerArray(size); this.tickUnit = checkNotNull(tickUnit); this.tick = currentTick(); }
RollingStats { public RollingStats(final int size, final TimeUnit tickUnit) { this.buckets = new AtomicIntegerArray(size); this.tickUnit = checkNotNull(tickUnit); this.tick = currentTick(); } }
RollingStats { public RollingStats(final int size, final TimeUnit tickUnit) { this.buckets = new AtomicIntegerArray(size); this.tickUnit = checkNotNull(tickUnit); this.tick = currentTick(); } RollingStats(final int size, final TimeUnit tickUnit); }
RollingStats { public RollingStats(final int size, final TimeUnit tickUnit) { this.buckets = new AtomicIntegerArray(size); this.tickUnit = checkNotNull(tickUnit); this.tick = currentTick(); } RollingStats(final int size, final TimeUnit tickUnit); void mark(); int sum(); }
RollingStats { public RollingStats(final int size, final TimeUnit tickUnit) { this.buckets = new AtomicIntegerArray(size); this.tickUnit = checkNotNull(tickUnit); this.tick = currentTick(); } RollingStats(final int size, final TimeUnit tickUnit); void mark(); int sum();  }