Histogram { public synchronized void clear() { this.buckets = new long[bucketType.getNumBuckets()]; this.numOfRecords = 0; this.numTopRecords = 0; this.numBottomRecords = 0; } 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 testClear() { Histogram histogram = Histogram.linear(0, 0.2, 50); histogram.record(-1, 1, 2, 3); assertThat(histogram.getTotalCount(), equalTo(4L)); assertThat(histogram.getCount(5), equalTo(1L)); histogram.clear(); assertThat(histogram.getTotalCount(), equalTo(0L)); assertThat(histogram.getCount(5), equalTo(0L)); }