update validate struct benchmark for lager struct with nested struct

pull/52/head
joeybloggs 10 years ago
parent beaa9adf31
commit fbb3befecb
  1. 45
      validator_test.go

@ -2326,17 +2326,46 @@ func BenchmarkValidateField(b *testing.B) {
}
func BenchmarkValidateStruct(b *testing.B) {
type Test struct {
StringVal string `bson:"required,lt=10"`
Int64Val int64 `bson:"gt=0,lt=10"`
}
t := &Test{
StringVal: "test",
Int64Val: 5,
// type Inner struct {
// }
// type Test struct {
// StringVal string `bson:"required,lt=10"`
// Int64Val int64 `bson:"gt=0,lt=10"`
// }
tFail := &TestString{
Required: "",
Len: "",
Min: "",
Max: "12345678901",
MinMax: "",
Lt: "0123456789",
Lte: "01234567890",
Gt: "1",
Gte: "1",
OmitEmpty: "12345678901",
Sub: &SubTest{
Test: "",
},
Anonymous: struct {
A string `validate:"required"`
}{
A: "",
},
Iface: &Impl{
F: "12",
},
}
// t := &Test{
// StringVal: "test",
// Int64Val: 5,
// }
for n := 0; n < b.N; n++ {
validate.Struct(t)
validate.Struct(tFail)
}
}

Loading…
Cancel
Save