Histogram { public double p90() { return getLinearInterpolation(0.90); } private  Histogram(BucketType bucketType); static Histogram linear(double start, double width, int numBuckets); void record(double... values); synchronized void clear(); synchronized void record(double value); synchronized long getTotalCount(); synchronized long getCount(int bucketIndex); double p99(); double p90(); double p50();  }
@Test public void testP90() { Histogram histogram1 = Histogram.linear(0, 0.2, 50); histogram1.record(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); assertThat(String.format("%.3f", histogram1.p90()), equalTo("8.200")); Histogram histogram2 = Histogram.linear(0, 0.02, 50); histogram2.record(0, 0, 0); assertThat(String.format("%.3f", histogram2.p90()), equalTo("0.018")); }