Search in sources :

Example 6 with FixedBucketsHistogram

use of org.apache.druid.query.aggregation.histogram.FixedBucketsHistogram in project druid by druid-io.

the class FixedHistogramAddBenchmark method addFixedHisto.

@Benchmark
public void addFixedHisto(Blackhole bh) {
    fixedHistogramForAdds = new FixedBucketsHistogram(LOWER_LIMIT, UPPER_LIMIT, numBuckets, FixedBucketsHistogram.OutlierHandlingMode.OVERFLOW);
    for (int i = 0; i < numEvents; i++) {
        fixedHistogramForAdds.add(randomValues[i]);
    }
    bh.consume(fixedHistogramForAdds);
}
Also used : FixedBucketsHistogram(org.apache.druid.query.aggregation.histogram.FixedBucketsHistogram) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 7 with FixedBucketsHistogram

use of org.apache.druid.query.aggregation.histogram.FixedBucketsHistogram in project druid by druid-io.

the class FixedHistogramBenchmark method deserializeFixedSparseLower.

@Benchmark
public void deserializeFixedSparseLower(Blackhole bh) {
    FixedBucketsHistogram fixedBucketsHistogram = FixedBucketsHistogram.fromBytes(fixedSparseLowerSerialized);
    bh.consume(fixedBucketsHistogram);
}
Also used : FixedBucketsHistogram(org.apache.druid.query.aggregation.histogram.FixedBucketsHistogram) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 8 with FixedBucketsHistogram

use of org.apache.druid.query.aggregation.histogram.FixedBucketsHistogram in project druid by druid-io.

the class FixedHistogramBenchmark method mergeFixedDifferentBuckets.

@Benchmark
public void mergeFixedDifferentBuckets(Blackhole bh) {
    FixedBucketsHistogram copy = fixedHistogram.getCopy();
    copy.combineHistogram(fixedHistogram2);
    bh.consume(copy);
}
Also used : FixedBucketsHistogram(org.apache.druid.query.aggregation.histogram.FixedBucketsHistogram) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 9 with FixedBucketsHistogram

use of org.apache.druid.query.aggregation.histogram.FixedBucketsHistogram in project druid by druid-io.

the class FixedHistogramBenchmark method setup.

@Setup
public void setup() {
    fixedHistogram = new FixedBucketsHistogram(LOWER_LIMIT, UPPER_LIMIT, numBuckets, FixedBucketsHistogram.OutlierHandlingMode.OVERFLOW);
    fixedHistogram2 = new FixedBucketsHistogram(LOWER_LIMIT, UPPER_LIMIT, (int) Math.round(numBuckets * 1.5), FixedBucketsHistogram.OutlierHandlingMode.OVERFLOW);
    fixedHistogram3 = new FixedBucketsHistogram(LOWER_LIMIT, UPPER_LIMIT, numBuckets, FixedBucketsHistogram.OutlierHandlingMode.OVERFLOW);
    fixedHistogramForSparseLower = new FixedBucketsHistogram(LOWER_LIMIT, UPPER_LIMIT, numBuckets, FixedBucketsHistogram.OutlierHandlingMode.OVERFLOW);
    fixedHistogramForSparseUpper = new FixedBucketsHistogram(LOWER_LIMIT, UPPER_LIMIT, numBuckets, FixedBucketsHistogram.OutlierHandlingMode.OVERFLOW);
    randomValues = new int[numEvents];
    Random r = ThreadLocalRandom.current();
    for (int i = 0; i < numEvents; i++) {
        randomValues[i] = r.nextInt(UPPER_LIMIT);
        fixedHistogram.add(randomValues[i]);
        fixedHistogram2.add(randomValues[i]);
        fixedHistogram3.add(randomValues[i]);
        if (randomValues[i] < UPPER_LIMIT * 0.4) {
            fixedHistogramForSparseLower.add(randomValues[i]);
        }
        if (randomValues[i] > UPPER_LIMIT * 0.6) {
            fixedHistogramForSparseUpper.add(randomValues[i]);
        }
    }
    fixedFullSerializedAlready = fixedHistogram.toBytesFull(true);
    fixedSparseLowerSerialized = fixedHistogramForSparseLower.toBytesSparse(fixedHistogram.getNonEmptyBucketCount());
    fixedSparseUpperSerialized = fixedHistogramForSparseUpper.toBytesSparse(fixedHistogram.getNonEmptyBucketCount());
}
Also used : Random(java.util.Random) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) FixedBucketsHistogram(org.apache.druid.query.aggregation.histogram.FixedBucketsHistogram) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

FixedBucketsHistogram (org.apache.druid.query.aggregation.histogram.FixedBucketsHistogram)9 Benchmark (org.openjdk.jmh.annotations.Benchmark)7 Random (java.util.Random)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 Setup (org.openjdk.jmh.annotations.Setup)2 NormalDistribution (org.apache.commons.math3.distribution.NormalDistribution)1