aboutsummaryrefslogtreecommitdiff
path: root/kamon-core-bench/src/main/scala/kamon/bench/TagSetLookupBenchmark.scala
diff options
context:
space:
mode:
Diffstat (limited to 'kamon-core-bench/src/main/scala/kamon/bench/TagSetLookupBenchmark.scala')
-rw-r--r--kamon-core-bench/src/main/scala/kamon/bench/TagSetLookupBenchmark.scala55
1 files changed, 55 insertions, 0 deletions
diff --git a/kamon-core-bench/src/main/scala/kamon/bench/TagSetLookupBenchmark.scala b/kamon-core-bench/src/main/scala/kamon/bench/TagSetLookupBenchmark.scala
new file mode 100644
index 00000000..b8a63d84
--- /dev/null
+++ b/kamon-core-bench/src/main/scala/kamon/bench/TagSetLookupBenchmark.scala
@@ -0,0 +1,55 @@
+package kamon.bench
+
+import java.util.concurrent.TimeUnit
+
+import kamon.tag.TagSet
+import org.openjdk.jmh.annotations._
+import kamon.tag.Lookups.any
+
+@BenchmarkMode(Array(Mode.AverageTime))
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(1)
+@State(Scope.Benchmark)
+class TagSetLookupBenchmark {
+
+ def builderTags() = TagSet.builder()
+ .add("http.url", "http://localhost:8080/test")
+ .add("http.status_code", 200L)
+ .add("error", false)
+ .add("userID", "abcdef")
+ .add("correlationID", "0123456")
+ .create()
+
+ def keyByKeyTags() = TagSet.Empty
+ .withTag("http.url", "http://localhost:8080/test")
+ .withTag("http.status_code", 200L)
+ .withTag("error", false)
+ .withTag("userID", "abcdef")
+ .withTag("correlationID", "0123456")
+
+
+ val builderLeft = builderTags()
+ val builderRight = builderTags()
+ val keyByKeyLeft = keyByKeyTags()
+ val keyByKeyRight = keyByKeyTags()
+
+ @Benchmark
+ def equalityOnBuilderTagSets(): Boolean = {
+ builderLeft == builderRight
+ }
+
+ @Benchmark
+ def equalityOnKeyByKeyTagSets(): Boolean = {
+ keyByKeyLeft == keyByKeyRight
+ }
+
+ @Benchmark
+ def anyLookupOnBuilderTagSet(): Any = {
+ builderLeft.get(any("userID"))
+ }
+
+ @Benchmark
+ def anyLookupOnKeyByKeyTagSet(): Any = {
+ keyByKeyLeft.get(any("userID"))
+ }
+}