blob: b8a63d84e988f8ad3e263bc52a8f5d473b575bf1 (
plain) (
blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
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"))
}
}
|