Assert.assertEquals(175, list.getPercentile(50));
}
@Test
public void testPercentileAlgorithm_Extremes() {
PercentileSnapshot p = new PercentileSnapshot(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 800, 768, 657, 700, 867);
System.out.println("0.01: " + p.getPercentile(0.01));
System.out.println("10th: " + p.getPercentile(10));
System.out.println("Median: " + p.getPercentile(50));
System.out.println("75th: " + p.getPercentile(75));
System.out.println("90th: " + p.getPercentile(90));
System.out.println("99th: " + p.getPercentile(99));
System.out.println("99.5th: " + p.getPercentile(99.5));
System.out.println("99.99: " + p.getPercentile(99.99));
Assert.assertEquals(2, p.getPercentile(50));
Assert.assertEquals(2, p.getPercentile(10));
Assert.assertEquals(2, p.getPercentile(75));
if (p.getPercentile(95) < 600) {
fail("We expect the 90th to be over 600 to show the extremes but got: " + p.getPercentile(90));
}
if (p.getPercentile(99) < 600) {
fail("We expect the 99th to be over 600 to show the extremes but got: " + p.getPercentile(99));
}
}