/** Tests recording of boolean histograms. */ @SmallTest public void testRecordBooleanHistogram() { String histogram = "HelloWorld.BooleanMetric"; HistogramDelta falseCount = new HistogramDelta(histogram, 0); HistogramDelta trueCount = new HistogramDelta(histogram, 1); assertEquals(0, trueCount.getDelta()); assertEquals(0, falseCount.getDelta()); RecordHistogram.recordBooleanHistogram(histogram, true); assertEquals(1, trueCount.getDelta()); assertEquals(0, falseCount.getDelta()); RecordHistogram.recordBooleanHistogram(histogram, true); assertEquals(2, trueCount.getDelta()); assertEquals(0, falseCount.getDelta()); RecordHistogram.recordBooleanHistogram(histogram, false); assertEquals(2, trueCount.getDelta()); assertEquals(1, falseCount.getDelta()); }
/** Tests recording of count histograms. */ @SmallTest public void testRecordCountHistogram() { String histogram = "HelloWorld.CountMetric"; HistogramDelta zeroCount = new HistogramDelta(histogram, 0); HistogramDelta oneCount = new HistogramDelta(histogram, 1); HistogramDelta twoCount = new HistogramDelta(histogram, 2); HistogramDelta eightThousandCount = new HistogramDelta(histogram, 8000); assertEquals(0, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); assertEquals(0, eightThousandCount.getDelta()); RecordHistogram.recordCountHistogram(histogram, 0); assertEquals(1, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); assertEquals(0, eightThousandCount.getDelta()); RecordHistogram.recordCountHistogram(histogram, 0); assertEquals(2, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); assertEquals(0, eightThousandCount.getDelta()); RecordHistogram.recordCountHistogram(histogram, 2); assertEquals(2, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(1, twoCount.getDelta()); assertEquals(0, eightThousandCount.getDelta()); RecordHistogram.recordCountHistogram(histogram, 8000); assertEquals(2, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(1, twoCount.getDelta()); assertEquals(1, eightThousandCount.getDelta()); }
/** Tests recording of enumerated histograms. */ @SmallTest public void testRecordEnumeratedHistogram() { String histogram = "HelloWorld.EnumeratedMetric"; HistogramDelta zeroCount = new HistogramDelta(histogram, 0); HistogramDelta oneCount = new HistogramDelta(histogram, 1); HistogramDelta twoCount = new HistogramDelta(histogram, 2); final int boundary = 3; assertEquals(0, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); RecordHistogram.recordEnumeratedHistogram(histogram, 0, boundary); assertEquals(1, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); RecordHistogram.recordEnumeratedHistogram(histogram, 0, boundary); assertEquals(2, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); RecordHistogram.recordEnumeratedHistogram(histogram, 2, boundary); assertEquals(2, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(1, twoCount.getDelta()); }
/** Tests recording of linear count histograms. */ @SmallTest public void testRecordLinearCountHistogram() { String histogram = "HelloWorld.LinearCountMetric"; HistogramDelta zeroCount = new HistogramDelta(histogram, 0); HistogramDelta oneCount = new HistogramDelta(histogram, 1); HistogramDelta twoCount = new HistogramDelta(histogram, 2); final int min = 1; final int max = 3; final int numBuckets = 4; assertEquals(0, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); RecordHistogram.recordLinearCountHistogram(histogram, 0, min, max, numBuckets); assertEquals(1, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); RecordHistogram.recordLinearCountHistogram(histogram, 0, min, max, numBuckets); assertEquals(2, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); RecordHistogram.recordLinearCountHistogram(histogram, 2, min, max, numBuckets); assertEquals(2, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(1, twoCount.getDelta()); }
/** Tests recording of custom times histograms. */ @SmallTest public void testRecordCustomTimesHistogram() { String histogram = "HelloWorld.CustomTimesMetric"; HistogramDelta zeroCount = new HistogramDelta(histogram, 0); HistogramDelta oneCount = new HistogramDelta(histogram, 1); HistogramDelta twoCount = new HistogramDelta(histogram, 100); assertEquals(0, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); TimeUnit milli = TimeUnit.MILLISECONDS; RecordHistogram.recordCustomTimesHistogram(histogram, 0, 1, 100, milli, 3); assertEquals(1, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); RecordHistogram.recordCustomTimesHistogram(histogram, 0, 1, 100, milli, 3); assertEquals(2, zeroCount.getDelta()); assertEquals(0, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); RecordHistogram.recordCustomTimesHistogram(histogram, 95, 1, 100, milli, 3); assertEquals(2, zeroCount.getDelta()); assertEquals(1, oneCount.getDelta()); assertEquals(0, twoCount.getDelta()); RecordHistogram.recordCustomTimesHistogram(histogram, 200, 1, 100, milli, 3); assertEquals(2, zeroCount.getDelta()); assertEquals(1, oneCount.getDelta()); assertEquals(1, twoCount.getDelta()); }