Skip to content

Commit fbb3bef

Browse files
joeybloggsjoeybloggs
authored andcommitted
update validate struct benchmark for lager struct with nested struct
1 parent beaa9ad commit fbb3bef

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

validator_test.go

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,17 +2326,46 @@ func BenchmarkValidateField(b *testing.B) {
23262326
}
23272327

23282328
func BenchmarkValidateStruct(b *testing.B) {
2329-
type Test struct {
2330-
StringVal string `bson:"required,lt=10"`
2331-
Int64Val int64 `bson:"gt=0,lt=10"`
2332-
}
23332329

2334-
t := &Test{
2335-
StringVal: "test",
2336-
Int64Val: 5,
2330+
// type Inner struct {
2331+
2332+
// }
2333+
2334+
// type Test struct {
2335+
// StringVal string `bson:"required,lt=10"`
2336+
// Int64Val int64 `bson:"gt=0,lt=10"`
2337+
// }
2338+
2339+
tFail := &TestString{
2340+
Required: "",
2341+
Len: "",
2342+
Min: "",
2343+
Max: "12345678901",
2344+
MinMax: "",
2345+
Lt: "0123456789",
2346+
Lte: "01234567890",
2347+
Gt: "1",
2348+
Gte: "1",
2349+
OmitEmpty: "12345678901",
2350+
Sub: &SubTest{
2351+
Test: "",
2352+
},
2353+
Anonymous: struct {
2354+
A string `validate:"required"`
2355+
}{
2356+
A: "",
2357+
},
2358+
Iface: &Impl{
2359+
F: "12",
2360+
},
23372361
}
23382362

2363+
// t := &Test{
2364+
// StringVal: "test",
2365+
// Int64Val: 5,
2366+
// }
2367+
23392368
for n := 0; n < b.N; n++ {
2340-
validate.Struct(t)
2369+
validate.Struct(tFail)
23412370
}
23422371
}

0 commit comments

Comments
 (0)