@Test public void testHonorsBufferLimit() { for (int i = 0; i < 1000; i++) { percentiles.record(0); } for (int i = 0; i < Percentile.MAX_BUFFER_SIZE; i++) { percentiles.record(1); } assertThat(percentiles.samples.size(), is(Percentile.MAX_BUFFER_SIZE)); checkPercentiles(percentiles, 1, 1, 1, 1, 1, 1, 1, 1); checkValuesAreFlushed(percentiles); }
public void record(T value) { if (sampler == null || sampler.select()) { synchronized (samples) { samples.addLast(value); while (samples.size() > MAX_BUFFER_SIZE) samples.removeFirst(); } } }
Percentile { public void record(T value) { if (sampler == null || sampler.select()) { synchronized (samples) { samples.addLast(value); while (samples.size() > MAX_BUFFER_SIZE) samples.removeFirst(); } } } }
Percentile { public void record(T value) { if (sampler == null || sampler.select()) { synchronized (samples) { samples.addLast(value); while (samples.size() > MAX_BUFFER_SIZE) samples.removeFirst(); } } } Percentile(String name, float samplePercent, double... percentiles);  Percentile(String name, Sampler sampler, double... percentiles);  Percentile(String name, int numSampleWindows,
      @Nullable Sampler sampler, double... percentiles); }
Percentile { public void record(T value) { if (sampler == null || sampler.select()) { synchronized (samples) { samples.addLast(value); while (samples.size() > MAX_BUFFER_SIZE) samples.removeFirst(); } } } Percentile(String name, float samplePercent, double... percentiles);  Percentile(String name, Sampler sampler, double... percentiles);  Percentile(String name, int numSampleWindows,
      @Nullable Sampler sampler, double... percentiles); Map<Double, ? extends Stat<?>> getPercentiles(); void record(T value); }
Percentile { public void record(T value) { if (sampler == null || sampler.select()) { synchronized (samples) { samples.addLast(value); while (samples.size() > MAX_BUFFER_SIZE) samples.removeFirst(); } } } Percentile(String name, float samplePercent, double... percentiles);  Percentile(String name, Sampler sampler, double... percentiles);  Percentile(String name, int numSampleWindows,
      @Nullable Sampler sampler, double... percentiles); Map<Double, ? extends Stat<?>> getPercentiles(); void record(T value);  }