File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package validator
3
3
import (
4
4
"bytes"
5
5
sql "database/sql/driver"
6
+ "errors"
6
7
"testing"
7
8
"time"
8
9
)
@@ -1097,3 +1098,39 @@ func BenchmarkOneofParallel(b *testing.B) {
1097
1098
}
1098
1099
})
1099
1100
}
1101
+
1102
+ type T struct {}
1103
+
1104
+ func (* T ) Validate () error { return errors .New ("ops" ) }
1105
+
1106
+ func BenchmarkValidateFnSequencial (b * testing.B ) {
1107
+ validate := New ()
1108
+
1109
+ type Test struct {
1110
+ T T `validate:"validateFn"`
1111
+ }
1112
+
1113
+ test := & Test {}
1114
+
1115
+ b .ResetTimer ()
1116
+ for n := 0 ; n < b .N ; n ++ {
1117
+ _ = validate .Struct (test )
1118
+ }
1119
+ }
1120
+
1121
+ func BenchmarkValidateFnParallel (b * testing.B ) {
1122
+ validate := New ()
1123
+
1124
+ type Test struct {
1125
+ T T `validate:"validateFn"`
1126
+ }
1127
+
1128
+ test := & Test {}
1129
+
1130
+ b .ResetTimer ()
1131
+ b .RunParallel (func (pb * testing.PB ) {
1132
+ for pb .Next () {
1133
+ _ = validate .Struct (test )
1134
+ }
1135
+ })
1136
+ }
You can’t perform that action at this time.
0 commit comments