aboutsummaryrefslogtreecommitdiff
path: root/kamon-core-bench
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2019-04-01 13:26:18 +0200
committerGitHub <noreply@github.com>2019-04-01 13:26:18 +0200
commit45237e2977d38053ddedc35765a901cf8771c106 (patch)
tree4c8ce6da2630dc92dc9f2b4d440b206177a4ab89 /kamon-core-bench
parent8efb3b408a876a3dfdac79580773279125cb4135 (diff)
parent2392fb02c3259d7f0b41ff410641accd818bc5d4 (diff)
downloadKamon-master.tar.gz
Kamon-master.tar.bz2
Kamon-master.zip
Merge pull request #572 from ivantopo/tagsHEADmaster
Introduce a common abstractions to handle tags
Diffstat (limited to 'kamon-core-bench')
-rw-r--r--kamon-core-bench/src/main/scala/kamon/bench/TagSetCreationBenchmark.scala42
-rw-r--r--kamon-core-bench/src/main/scala/kamon/bench/TagSetLookupBenchmark.scala55
2 files changed, 97 insertions, 0 deletions
diff --git a/kamon-core-bench/src/main/scala/kamon/bench/TagSetCreationBenchmark.scala b/kamon-core-bench/src/main/scala/kamon/bench/TagSetCreationBenchmark.scala
new file mode 100644
index 00000000..9b8f1d7a
--- /dev/null
+++ b/kamon-core-bench/src/main/scala/kamon/bench/TagSetCreationBenchmark.scala
@@ -0,0 +1,42 @@
+package kamon.bench
+
+import java.util.concurrent.TimeUnit
+
+import kamon.tag.TagSet
+import org.openjdk.jmh.annotations._
+
+@BenchmarkMode(Array(Mode.AverageTime))
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(1)
+@State(Scope.Benchmark)
+class TagSetCreationBenchmark {
+
+ @Param(Array("1", "2", "3", "4", "5", "6"))
+ var tagCount: Int = 1
+
+ @Benchmark
+ def createTagSetFromIndividualKeys(): TagSet = {
+ var tags = TagSet.Empty
+ tags = tags.withTag("http.method", "POST")
+ if(tagCount > 1) tags = tags.withTag("http.url", "http://localhost:8080/test")
+ if(tagCount > 2) tags = tags.withTag("http.status_code", 200L)
+ if(tagCount > 3) tags = tags.withTag("error", false)
+ if(tagCount > 4) tags = tags.withTag("userID", "abcdef")
+ if(tagCount > 5) tags = tags.withTag("correlationID", "0123456")
+
+ tags
+ }
+
+ @Benchmark
+ def createTagSetFromBuilder(): TagSet = {
+ val tags = TagSet.builder()
+ tags.add("http.method", "POST")
+ if(tagCount > 1) tags.add("http.url", "http://localhost:8080/test")
+ if(tagCount > 2) tags.add("http.status_code", 200L)
+ if(tagCount > 3) tags.add("error", false)
+ if(tagCount > 4) tags.add("userID", "abcdef")
+ if(tagCount > 5) tags.add("correlationID", "0123456")
+
+ tags.create()
+ }
+}
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"))
+ }
+}