Search in sources :

Example 1 with WindowedApproxHistogram

use of com.twitter.common.stats.WindowedApproxHistogram in project commons by twitter.

the class MetricsInsertionBench method setUp.

@Override
protected void setUp() {
    metrics = Metrics.createDetached();
    counter = metrics.createCounter("counter");
    h = metrics.createHistogram("histogram");
    wh = new WindowedApproxHistogram();
    ws = new WindowedStatistics();
}
Also used : WindowedApproxHistogram(com.twitter.common.stats.WindowedApproxHistogram) WindowedStatistics(com.twitter.common.stats.WindowedStatistics)

Example 2 with WindowedApproxHistogram

use of com.twitter.common.stats.WindowedApproxHistogram 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)

Example 3 with WindowedApproxHistogram

use of com.twitter.common.stats.WindowedApproxHistogram in project commons by twitter.

the class MetricsCreationBench method timeCreatingWindowedHistogram.

/**
   * WindowedHistogram is serie of ApproximateHistograms in sliding window.
   */
public void timeCreatingWindowedHistogram(int n) {
    WindowedApproxHistogram h;
    int i = n;
    while (i != 0) {
        h = new WindowedApproxHistogram();
        h.add(1);
        i--;
    }
}
Also used : WindowedApproxHistogram(com.twitter.common.stats.WindowedApproxHistogram)

Aggregations

WindowedApproxHistogram (com.twitter.common.stats.WindowedApproxHistogram)3 WindowedStatistics (com.twitter.common.stats.WindowedStatistics)2 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 FakeClock (com.twitter.common.util.testing.FakeClock)1