@@ -24,23 +24,23 @@ func BenchmarkValidateStructSimple(b *testing.B) {
2424 }
2525}
2626
27- // func BenchmarkTemplateParallelSimple(b *testing.B) {
27+ func BenchmarkTemplateParallelSimple (b * testing.B ) {
2828
29- // type Foo struct {
30- // StringValue string `validate:"min=5,max=10"`
31- // IntValue int `validate:"min=5,max=10"`
32- // }
29+ type Foo struct {
30+ StringValue string `validate:"min=5,max=10"`
31+ IntValue int `validate:"min=5,max=10"`
32+ }
3333
34- // validFoo := &Foo{StringValue: "Foobar", IntValue: 7}
35- // invalidFoo := &Foo{StringValue: "Fo", IntValue: 3}
34+ validFoo := & Foo {StringValue : "Foobar" , IntValue : 7 }
35+ invalidFoo := & Foo {StringValue : "Fo" , IntValue : 3 }
3636
37- // b.RunParallel(func(pb *testing.PB) {
38- // for pb.Next() {
39- // validate.Struct(validFoo)
40- // validate.Struct(invalidFoo)
41- // }
42- // })
43- // }
37+ b .RunParallel (func (pb * testing.PB ) {
38+ for pb .Next () {
39+ validate .Struct (validFoo )
40+ validate .Struct (invalidFoo )
41+ }
42+ })
43+ }
4444
4545func BenchmarkValidateStructLarge (b * testing.B ) {
4646
@@ -101,63 +101,63 @@ func BenchmarkValidateStructLarge(b *testing.B) {
101101 }
102102}
103103
104- // func BenchmarkTemplateParallelLarge(b *testing.B) {
105-
106- // tFail := &TestString{
107- // Required: "",
108- // Len: "",
109- // Min: "",
110- // Max: "12345678901",
111- // MinMax: "",
112- // Lt: "0123456789",
113- // Lte: "01234567890",
114- // Gt: "1",
115- // Gte: "1",
116- // OmitEmpty: "12345678901",
117- // Sub: &SubTest{
118- // Test: "",
119- // },
120- // Anonymous: struct {
121- // A string `validate:"required"`
122- // }{
123- // A: "",
124- // },
125- // Iface: &Impl{
126- // F: "12",
127- // },
128- // }
129-
130- // tSuccess := &TestString{
131- // Required: "Required",
132- // Len: "length==10",
133- // Min: "min=1",
134- // Max: "1234567890",
135- // MinMax: "12345",
136- // Lt: "012345678",
137- // Lte: "0123456789",
138- // Gt: "01234567890",
139- // Gte: "0123456789",
140- // OmitEmpty: "",
141- // Sub: &SubTest{
142- // Test: "1",
143- // },
144- // SubIgnore: &SubTest{
145- // Test: "",
146- // },
147- // Anonymous: struct {
148- // A string `validate:"required"`
149- // }{
150- // A: "1",
151- // },
152- // Iface: &Impl{
153- // F: "123",
154- // },
155- // }
156-
157- // b.RunParallel(func(pb *testing.PB) {
158- // for pb.Next() {
159- // validate.Struct(tSuccess)
160- // validate.Struct(tFail)
161- // }
162- // })
163- // }
104+ func BenchmarkTemplateParallelLarge (b * testing.B ) {
105+
106+ tFail := & TestString {
107+ Required : "" ,
108+ Len : "" ,
109+ Min : "" ,
110+ Max : "12345678901" ,
111+ MinMax : "" ,
112+ Lt : "0123456789" ,
113+ Lte : "01234567890" ,
114+ Gt : "1" ,
115+ Gte : "1" ,
116+ OmitEmpty : "12345678901" ,
117+ Sub : & SubTest {
118+ Test : "" ,
119+ },
120+ Anonymous : struct {
121+ A string `validate:"required"`
122+ }{
123+ A : "" ,
124+ },
125+ Iface : & Impl {
126+ F : "12" ,
127+ },
128+ }
129+
130+ tSuccess := & TestString {
131+ Required : "Required" ,
132+ Len : "length==10" ,
133+ Min : "min=1" ,
134+ Max : "1234567890" ,
135+ MinMax : "12345" ,
136+ Lt : "012345678" ,
137+ Lte : "0123456789" ,
138+ Gt : "01234567890" ,
139+ Gte : "0123456789" ,
140+ OmitEmpty : "" ,
141+ Sub : & SubTest {
142+ Test : "1" ,
143+ },
144+ SubIgnore : & SubTest {
145+ Test : "" ,
146+ },
147+ Anonymous : struct {
148+ A string `validate:"required"`
149+ }{
150+ A : "1" ,
151+ },
152+ Iface : & Impl {
153+ F : "123" ,
154+ },
155+ }
156+
157+ b .RunParallel (func (pb * testing.PB ) {
158+ for pb .Next () {
159+ validate .Struct (tSuccess )
160+ validate .Struct (tFail )
161+ }
162+ })
163+ }
0 commit comments