Search in sources :

Example 1 with Histogram

use of com.twitter.common.metrics.Histogram in project commons by twitter.

the class MetricsQueryBench method setUp.

@Override
protected void setUp() {
    metrics = Metrics.createDetached();
    FakeClock clock = new FakeClock();
    Amount<Long, Time> window = WindowedApproxHistogram.DEFAULT_WINDOW;
    int slices = WindowedApproxHistogram.DEFAULT_SLICES;
    Amount<Long, Time> delta = Amount.of(window.as(Time.MILLISECONDS) / N, Time.MILLISECONDS);
    Amount<Long, Data> maxMem = WindowedApproxHistogram.DEFAULT_MAX_MEMORY;
    for (int i = 0; i < 10; i++) {
        metrics.createCounter("counter-" + i).increment();
        HistogramInterface h = new Histogram("hist-" + i, window, slices, maxMem, null, Histogram.DEFAULT_QUANTILES, clock, metrics);
        for (int j = 0; j < N; j++) {
            h.add(j);
            clock.advance(delta);
        }
    }
    // Initialize Histograms and fill them with values (in every buckets for windowed ones)
    hist = new Histogram("hist", window, slices, maxMem, null, Histogram.DEFAULT_QUANTILES, clock);
    approxHist = new WindowedApproxHistogram(window, slices, maxMem, clock);
    winStats = new WindowedStatistics(window, slices, clock);
    for (int j = 0; j < N; j++) {
        hist.add(j);
        approxHist.add(j);
        winStats.accumulate(j);
        clock.advance(delta);
    }
}
Also used : Histogram(com.twitter.common.metrics.Histogram) WindowedApproxHistogram(com.twitter.common.stats.WindowedApproxHistogram) WindowedApproxHistogram(com.twitter.common.stats.WindowedApproxHistogram) FakeClock(com.twitter.common.util.testing.FakeClock) Time(com.twitter.common.quantity.Time) Data(com.twitter.common.quantity.Data) HistogramInterface(com.twitter.common.metrics.HistogramInterface) WindowedStatistics(com.twitter.common.stats.WindowedStatistics)

Aggregations

Histogram (com.twitter.common.metrics.Histogram)1 HistogramInterface (com.twitter.common.metrics.HistogramInterface)1 Data (com.twitter.common.quantity.Data)1 Time (com.twitter.common.quantity.Time)1 WindowedApproxHistogram (com.twitter.common.stats.WindowedApproxHistogram)1 WindowedStatistics (com.twitter.common.stats.WindowedStatistics)1 FakeClock (com.twitter.common.util.testing.FakeClock)1