diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2019-03-25 16:29:21 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2019-03-27 13:56:30 +0100 |
commit | 2392fb02c3259d7f0b41ff410641accd818bc5d4 (patch) | |
tree | 4c8ce6da2630dc92dc9f2b4d440b206177a4ab89 /kamon-core-bench/src/main/scala/kamon/bench/TagSetCreationBenchmark.scala | |
parent | 91575b8db60ca4fc6df9f44fa720929d8c3868ac (diff) | |
download | Kamon-2392fb02c3259d7f0b41ff410641accd818bc5d4.tar.gz Kamon-2392fb02c3259d7f0b41ff410641accd818bc5d4.tar.bz2 Kamon-2392fb02c3259d7f0b41ff410641accd818bc5d4.zip |
Introduce a TagSet builder and use UnifiedMap from Eclipse Collections
as the underlying storage for TagSets.
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.scala | 42 |
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() + } +} |