File tree 1 file changed +44
-0
lines changed
1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -40,3 +40,47 @@ func Test_isAllowedErrAndFunc(t *testing.T) {
40
40
})
41
41
}
42
42
}
43
+
44
+ func Benchmark_isAllowedErrAndFunc (b * testing.B ) {
45
+ var benchCases = []struct {
46
+ desc string
47
+ err string
48
+ fun string
49
+ }{
50
+ {
51
+ desc : "empty" ,
52
+ err : "" ,
53
+ fun : "" ,
54
+ },
55
+ {
56
+ desc : "short" ,
57
+ err : "x" ,
58
+ fun : "x" ,
59
+ },
60
+ {
61
+ desc : "long not existed" ,
62
+ // should pass strings.HasPrefix length check, 30 symbols here
63
+ err : "xxxx_xxxx_yyyy_yyyy_zzzz_zzzz_" ,
64
+ fun : "xxxx_xxxx_yyyy_yyyy_zzzz_zzzz_" ,
65
+ },
66
+ {
67
+ desc : "existed, not wildcard" ,
68
+ err : "io.EOF" ,
69
+ fun : "(io.Reader).Read" ,
70
+ },
71
+ {
72
+ desc : "existed, wildcard" ,
73
+ err : "golang.org/x/sys/unix.Exx" ,
74
+ fun : "golang.org/x/sys/unix.xxx" ,
75
+ },
76
+ }
77
+ for _ , bb := range benchCases {
78
+ b .Run (bb .desc , func (b * testing.B ) {
79
+ err , fun := bb .err , bb .fun
80
+ b .ResetTimer ()
81
+ for i := 0 ; i < b .N ; i ++ {
82
+ isAllowedErrAndFunc (err , fun )
83
+ }
84
+ })
85
+ }
86
+ }
You can’t perform that action at this time.
0 commit comments