-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
errors_benchmark_test.go
57 lines (48 loc) · 1.17 KB
/
errors_benchmark_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
// Copyright 2022 Ainsley Clark. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package errors
import (
"errors"
"testing"
)
func BenchmarkNew(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = NewE(errors.New("error"), "message", INTERNAL)
}
}
func BenchmarkNewInternal(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = NewE(errors.New("error"), "message", INTERNAL)
}
}
func BenchmarkError_Error(b *testing.B) {
e := NewE(errors.New("error"), "message", INTERNAL)
for i := 0; i < b.N; i++ {
_ = e.Error()
}
}
func BenchmarkError_Code(b *testing.B) {
e := NewE(errors.New("error"), "message", INTERNAL)
for i := 0; i < b.N; i++ {
_ = Code(e)
}
}
func BenchmarkError_Message(b *testing.B) {
e := NewE(errors.New("error"), "message", INTERNAL)
for i := 0; i < b.N; i++ {
_ = Message(e)
}
}
func BenchmarkError_ToError(b *testing.B) {
e := NewE(errors.New("error"), "message", INTERNAL)
for i := 0; i < b.N; i++ {
_ = ToError(e)
}
}
func BenchmarkError_HTTPStatusCode(b *testing.B) {
e := NewE(errors.New("error"), "message", INTERNAL)
for i := 0; i < b.N; i++ {
_ = e.HTTPStatusCode()
}
}