PercentileTracker { public double getPercentile(int requestedPercentile) { return getPercentile(requestedPercentile, new ArrayList<Double>(cslm.values())); } PercentileTracker(long windowMillis); synchronized void update(double sample); double getPercentile(int requestedPercentile);  }
@Test public void testEmptyPercentileTrackerDoesNotNPE() { PercentileTracker pt = new PercentileTracker(5000); try { pt.getPercentile(99); } catch (Exception e) { fail(); } }
@Test public void test90ithPercentile () { PercentileTracker pt = new PercentileTracker(5000); double value = pt.getPercentile(90, normalizedTestArray); Assert.assertEquals(9d, value, 0); }
@Test public void test95ithPercentile () { PercentileTracker pt = new PercentileTracker(5000); double value = pt.getPercentile(95, normalizedTestArray); Assert.assertEquals(9.5d, value, 0); }