use of com.twitter.common.stats.testing.RealHistogram in project commons by twitter.
the class WindowedHistogramTest method testWinHistogramAccuracy.
@Test
public void testWinHistogramAccuracy() {
FakeClock ticker = new FakeClock();
Amount<Long, Time> window = Amount.of(100L, Time.MILLISECONDS);
int slices = 10;
Amount<Long, Time> sliceDuration = Amount.of(window.as(Time.NANOSECONDS) / slices, Time.NANOSECONDS);
WindowedHistogram<?> wh = createFullHistogram(window, slices, ticker);
RealHistogram rh = fillHistogram(new RealHistogram(), sliceDuration, slices, new FakeClock());
assertEquals(wh.getQuantile(0.5), rh.getQuantile(0.5));
assertEquals(wh.getQuantile(0.75), rh.getQuantile(0.75));
assertEquals(wh.getQuantile(0.9), rh.getQuantile(0.9));
assertEquals(wh.getQuantile(0.99), rh.getQuantile(0.99));
}
use of com.twitter.common.stats.testing.RealHistogram in project commons by twitter.
the class MetricsPrecisionDemo method main.
public static void main(String[] args) {
MetricsPrecisionDemo demo = new MetricsPrecisionDemo();
for (int n = 100; n <= 1000 * 1000; n *= 10) {
for (long mem = 4; mem < 16; mem += 2) {
Amount<Long, Data> maxMemory = Amount.of(mem, Data.KB);
System.out.println("\nnumber of elements:" + n + " maxMemory:" + maxMemory);
System.out.println("Real data");
demo.testHistogram(new ApproximateHistogram(maxMemory), new RealHistogram(), demo.getRealData(n));
System.out.println("Random data");
demo.testHistogram(new ApproximateHistogram(maxMemory), new RealHistogram(), demo.getRandomData(n, 100000, 200000));
}
}
}
Aggregations