aboutsummaryrefslogtreecommitdiff
path: root/kamon-core-bench/src/main/scala/kamon/bench/TagSetCreationBenchmark.scala
diff options
context:
space:
mode:
Diffstat (limited to 'kamon-core-bench/src/main/scala/kamon/bench/TagSetCreationBenchmark.scala')
-rw-r--r--kamon-core-bench/src/main/scala/kamon/bench/TagSetCreationBenchmark.scala42
1 files changed, 42 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()
+ }
+}