Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/jmh/java/com/datadoghq/sketch/ddsketch/DDSketchOption.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.datadoghq.sketch.ddsketch;

import com.datadoghq.sketch.ddsketch.mapping.BitwiseLinearlyInterpolatedMapping;
import com.datadoghq.sketch.ddsketch.store.PaginatedStore;
import com.datadoghq.sketch.ddsketch.store.UnboundedSizeDenseStore;

import java.util.function.DoubleFunction;

public enum DDSketchOption {
FAST(DDSketch::fast),
MEMORY_OPTIMAL(DDSketch::memoryOptimal),
BALANCED(DDSketch::balanced);
FAST(relativeAccuracy -> new DDSketch(new BitwiseLinearlyInterpolatedMapping(relativeAccuracy), UnboundedSizeDenseStore::new)),
MEMORY_OPTIMAL(DDSketches::logarithmicUnboundedDense),
BALANCED(DDSketches::unboundedDense),
PAGINATED(relativeAccuracy -> new DDSketch(new BitwiseLinearlyInterpolatedMapping(relativeAccuracy), PaginatedStore::new));

private final DoubleFunction<DDSketch> creator;

Expand Down
50 changes: 50 additions & 0 deletions src/jmh/java/com/datadoghq/sketch/ddsketch/benchmarks/Merge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.datadoghq.sketch.ddsketch.benchmarks;

import com.datadoghq.sketch.ddsketch.DDSketch;
import com.datadoghq.sketch.ddsketch.DDSketchOption;
import com.datadoghq.sketch.ddsketch.DataGenerator;
import org.openjdk.jmh.annotations.*;

import java.util.concurrent.TimeUnit;

@State(Scope.Benchmark)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@BenchmarkMode(Mode.AverageTime)
public class Merge {

@Param
DataGenerator generator;

@Param({"NANOSECONDS", "MICROSECONDS", "MILLISECONDS"})
TimeUnit unit;

@Param
DDSketchOption sketchOption;

@Param("100000")
int count;

@Param({"0.01"})
double relativeAccuracy;

DDSketch left;
DDSketch right;

@Setup(Level.Trial)
public void init() {
this.left = sketchOption.create(relativeAccuracy);
this.right = sketchOption.create(relativeAccuracy);
for (int i = 0; i < count; ++i) {
left.accept(unit.toNanos(Math.abs(Math.round(generator.nextValue()))));
right.accept(unit.toNanos(Math.abs(Math.round(generator.nextValue()))));
}
}

@Benchmark
public Object merge() {
DDSketch target = sketchOption.create(relativeAccuracy);
target.mergeWith(left);
target.mergeWith(right);
return target;
}
}
Loading