-
Notifications
You must be signed in to change notification settings - Fork 4
/
benchmarks_test.go
58 lines (50 loc) · 1.08 KB
/
benchmarks_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
50
51
52
53
54
55
56
57
58
package errors
import (
"testing"
)
func BenchmarkErrorNew(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = New("base error")
}
}
func BenchmarkErrorWrap(b *testing.B) {
err := New("base error")
for i := 0; i < b.N; i++ {
_ = Wrap(err, "wrapped error")
}
}
func BenchmarkErrorParallelNew(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
_ = New("base error")
}
})
}
func BenchmarkErrorPrint(b *testing.B) {
err := New("base error")
for i := 0; i < b.N; i++ {
_ = err.Error()
}
}
func BenchmarkErrorParallelPrint(b *testing.B) {
err := New("base error")
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
_ = err.Error()
}
})
}
func BenchmarkErrorPrintWithTagsAndTypes(b *testing.B) {
err := New("base error").AddTag("key", "value").AddTypes("Permanent", "Other")
for i := 0; i < b.N; i++ {
_ = err.Error()
}
}
func BenchmarkErrorParallelPrintWithTagsAndTypes(b *testing.B) {
err := New("base error").AddTag("key", "value").AddTypes("Permanent", "Other")
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
_ = err.Error()
}
})
}