forked from github/multus-cni
Update libcni to 0.7.0 (Spec ver 0.4.0)
This commit is contained in:
committed by
dougbtv
parent
41160c62d6
commit
0b153cd941
55
vendor/github.com/pkg/errors/bench_test.go
generated
vendored
55
vendor/github.com/pkg/errors/bench_test.go
generated
vendored
@@ -15,7 +15,6 @@ func noErrors(at, depth int) error {
|
||||
}
|
||||
return noErrors(at+1, depth)
|
||||
}
|
||||
|
||||
func yesErrors(at, depth int) error {
|
||||
if at >= depth {
|
||||
return New("ye error")
|
||||
@@ -23,11 +22,8 @@ func yesErrors(at, depth int) error {
|
||||
return yesErrors(at+1, depth)
|
||||
}
|
||||
|
||||
// GlobalE is an exported global to store the result of benchmark results,
|
||||
// preventing the compiler from optimising the benchmark functions away.
|
||||
var GlobalE interface{}
|
||||
|
||||
func BenchmarkErrors(b *testing.B) {
|
||||
var toperr error
|
||||
type run struct {
|
||||
stack int
|
||||
std bool
|
||||
@@ -57,54 +53,7 @@ func BenchmarkErrors(b *testing.B) {
|
||||
err = f(0, r.stack)
|
||||
}
|
||||
b.StopTimer()
|
||||
GlobalE = err
|
||||
toperr = err
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkStackFormatting(b *testing.B) {
|
||||
type run struct {
|
||||
stack int
|
||||
format string
|
||||
}
|
||||
runs := []run{
|
||||
{10, "%s"},
|
||||
{10, "%v"},
|
||||
{10, "%+v"},
|
||||
{30, "%s"},
|
||||
{30, "%v"},
|
||||
{30, "%+v"},
|
||||
{60, "%s"},
|
||||
{60, "%v"},
|
||||
{60, "%+v"},
|
||||
}
|
||||
|
||||
var stackStr string
|
||||
for _, r := range runs {
|
||||
name := fmt.Sprintf("%s-stack-%d", r.format, r.stack)
|
||||
b.Run(name, func(b *testing.B) {
|
||||
err := yesErrors(0, r.stack)
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
stackStr = fmt.Sprintf(r.format, err)
|
||||
}
|
||||
b.StopTimer()
|
||||
})
|
||||
}
|
||||
|
||||
for _, r := range runs {
|
||||
name := fmt.Sprintf("%s-stacktrace-%d", r.format, r.stack)
|
||||
b.Run(name, func(b *testing.B) {
|
||||
err := yesErrors(0, r.stack)
|
||||
st := err.(*fundamental).stack.StackTrace()
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
stackStr = fmt.Sprintf(r.format, st)
|
||||
}
|
||||
b.StopTimer()
|
||||
})
|
||||
}
|
||||
GlobalE = stackStr
|
||||
}
|
||||
|
Reference in New Issue
Block a user