2022-05-28 05:42:28 +03:00
|
|
|
// Copyright 2022 Gin Core Team. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2021-06-28 17:05:29 +03:00
|
|
|
package binding
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"strconv"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2021-11-21 16:45:03 +03:00
|
|
|
func BenchmarkSliceValidationError(b *testing.B) {
|
2021-06-28 17:05:29 +03:00
|
|
|
const size int = 100
|
2024-05-13 08:32:46 +03:00
|
|
|
e := make(SliceValidationError, size)
|
|
|
|
for j := 0; j < size; j++ {
|
|
|
|
e[j] = errors.New(strconv.Itoa(j))
|
|
|
|
}
|
|
|
|
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
|
2021-06-28 17:05:29 +03:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
if len(e.Error()) == 0 {
|
|
|
|
b.Errorf("error")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|