aboutsummaryrefslogtreecommitdiff
path: root/kamon-bench/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'kamon-bench/src/main')
-rw-r--r--kamon-bench/src/main/resources/application.conf3
-rw-r--r--kamon-bench/src/main/scala/kamon/bench/instruments/KamonCounterBench.scala34
-rw-r--r--kamon-bench/src/main/scala/kamon/bench/instruments/KamonMinMaxCounterBench.scala35
3 files changed, 72 insertions, 0 deletions
diff --git a/kamon-bench/src/main/resources/application.conf b/kamon-bench/src/main/resources/application.conf
new file mode 100644
index 00000000..9c5fec18
--- /dev/null
+++ b/kamon-bench/src/main/resources/application.conf
@@ -0,0 +1,3 @@
+kamon.metric {
+ tick-interval = 1 hour
+} \ No newline at end of file
diff --git a/kamon-bench/src/main/scala/kamon/bench/instruments/KamonCounterBench.scala b/kamon-bench/src/main/scala/kamon/bench/instruments/KamonCounterBench.scala
new file mode 100644
index 00000000..01162d53
--- /dev/null
+++ b/kamon-bench/src/main/scala/kamon/bench/instruments/KamonCounterBench.scala
@@ -0,0 +1,34 @@
+package kamon.bench.instruments
+
+import java.nio.LongBuffer
+import java.util.concurrent.TimeUnit
+
+import kamon.metric.instrument.{CollectionContext, LongAdderCounter}
+import org.openjdk.jmh.annotations._
+
+@State(Scope.Group)
+@BenchmarkMode(Array(Mode.AverageTime))
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(2)
+@Warmup(iterations = 10)
+@Measurement(iterations = 10)
+class KamonCounterBench {
+
+ val counter: LongAdderCounter = new LongAdderCounter
+
+ val collectionContext = new CollectionContext {
+ val buffer: LongBuffer = LongBuffer.allocate(33792)
+ }
+
+ @Benchmark
+ @Group("rw")
+ def increment(): Unit = {
+ counter.increment()
+ }
+
+ @Benchmark
+ @Group("rw")
+ def get(): Long = {
+ counter.collect(collectionContext).count
+ }
+}
diff --git a/kamon-bench/src/main/scala/kamon/bench/instruments/KamonMinMaxCounterBench.scala b/kamon-bench/src/main/scala/kamon/bench/instruments/KamonMinMaxCounterBench.scala
new file mode 100644
index 00000000..5b9de062
--- /dev/null
+++ b/kamon-bench/src/main/scala/kamon/bench/instruments/KamonMinMaxCounterBench.scala
@@ -0,0 +1,35 @@
+package kamon.bench.instruments
+
+import java.nio.LongBuffer
+import java.util.concurrent.TimeUnit
+
+import kamon.metric.instrument.Histogram.DynamicRange
+import kamon.metric.instrument.{CollectionContext, Histogram, PaddedMinMaxCounter}
+import org.openjdk.jmh.annotations._
+
+@State(Scope.Group)
+@BenchmarkMode(Array(Mode.AverageTime))
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(2)
+@Warmup(iterations = 10)
+@Measurement(iterations = 10)
+class KamonMinMaxCounterBench {
+
+ val counter: PaddedMinMaxCounter = new PaddedMinMaxCounter(Histogram(DynamicRange(1L, 999999999L, 2)))
+
+ val collectionContext = new CollectionContext {
+ val buffer: LongBuffer = LongBuffer.allocate(33792)
+ }
+
+ @Benchmark
+ @Group("rw")
+ def increment(): Unit = {
+ counter.increment()
+ }
+
+ @Benchmark
+ @Group("rw")
+ def get(): Long = {
+ counter.collect(collectionContext).min
+ }
+}