-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
performance_test.go
49 lines (45 loc) · 1.07 KB
/
performance_test.go
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
package urn
import (
"fmt"
"testing"
)
var benchs = []testCase{
urn2141OnlyTestCases[14],
urn2141OnlyTestCases[2],
urn2141OnlyTestCases[6],
urn2141OnlyTestCases[10],
urn2141OnlyTestCases[11],
urn2141OnlyTestCases[13],
urn2141OnlyTestCases[20],
urn2141OnlyTestCases[23],
urn2141OnlyTestCases[33],
urn2141OnlyTestCases[45],
urn2141OnlyTestCases[47],
urn2141OnlyTestCases[48],
urn2141OnlyTestCases[50],
urn2141OnlyTestCases[52],
urn2141OnlyTestCases[53],
urn2141OnlyTestCases[57],
urn2141OnlyTestCases[62],
urn2141OnlyTestCases[63],
urn2141OnlyTestCases[67],
urn2141OnlyTestCases[60],
}
// This is here to avoid compiler optimizations that
// could remove the actual call we are benchmarking
// during benchmarks
var benchParseResult *URN
func BenchmarkParse(b *testing.B) {
for ii, tt := range benchs {
tt := tt
outcome := (map[bool]string{true: "ok", false: "no"})[tt.ok]
b.Run(
fmt.Sprintf("%s/%02d/%s/", outcome, ii, rxpad(string(tt.in), 45)),
func(b *testing.B) {
for i := 0; i < b.N; i++ {
benchParseResult, _ = Parse(tt.in)
}
},
)
}
}