1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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()
}
}
|