From fbb3befecb265395163a09c8b110913250ea5955 Mon Sep 17 00:00:00 2001 From: joeybloggs Date: Sat, 30 May 2015 21:01:11 -0400 Subject: [PATCH] update validate struct benchmark for lager struct with nested struct --- validator_test.go | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/validator_test.go b/validator_test.go index 517d720..ce7c546 100644 --- a/validator_test.go +++ b/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) } }