OSDN Git Service

new repo
[bytom/vapor.git] / vendor / gopkg.in / go-playground / validator.v9 / benchmarks_test.go
1 package validator
2
3 import (
4         "bytes"
5         sql "database/sql/driver"
6         "testing"
7         "time"
8 )
9
10 func BenchmarkFieldSuccess(b *testing.B) {
11
12         validate := New()
13
14         s := "1"
15
16         b.ResetTimer()
17         for n := 0; n < b.N; n++ {
18                 validate.Var(&s, "len=1")
19         }
20 }
21
22 func BenchmarkFieldSuccessParallel(b *testing.B) {
23
24         validate := New()
25
26         s := "1"
27
28         b.ResetTimer()
29         b.RunParallel(func(pb *testing.PB) {
30                 for pb.Next() {
31                         validate.Var(&s, "len=1")
32                 }
33         })
34 }
35
36 func BenchmarkFieldFailure(b *testing.B) {
37
38         validate := New()
39
40         s := "12"
41
42         b.ResetTimer()
43         for n := 0; n < b.N; n++ {
44                 validate.Var(&s, "len=1")
45         }
46 }
47
48 func BenchmarkFieldFailureParallel(b *testing.B) {
49
50         validate := New()
51
52         s := "12"
53
54         b.ResetTimer()
55         b.RunParallel(func(pb *testing.PB) {
56                 for pb.Next() {
57                         validate.Var(&s, "len=1")
58                 }
59         })
60 }
61
62 func BenchmarkFieldDiveSuccess(b *testing.B) {
63
64         validate := New()
65
66         m := []string{"val1", "val2", "val3"}
67
68         b.ResetTimer()
69
70         for n := 0; n < b.N; n++ {
71                 validate.Var(m, "required,dive,required")
72         }
73 }
74
75 func BenchmarkFieldDiveSuccessParallel(b *testing.B) {
76
77         validate := New()
78
79         m := []string{"val1", "val2", "val3"}
80
81         b.ResetTimer()
82         b.RunParallel(func(pb *testing.PB) {
83                 for pb.Next() {
84                         validate.Var(m, "required,dive,required")
85                 }
86         })
87 }
88
89 func BenchmarkFieldDiveFailure(b *testing.B) {
90
91         validate := New()
92
93         m := []string{"val1", "", "val3"}
94
95         b.ResetTimer()
96         for n := 0; n < b.N; n++ {
97                 validate.Var(m, "required,dive,required")
98         }
99 }
100
101 func BenchmarkFieldDiveFailureParallel(b *testing.B) {
102
103         validate := New()
104
105         m := []string{"val1", "", "val3"}
106
107         b.ResetTimer()
108         b.RunParallel(func(pb *testing.PB) {
109                 for pb.Next() {
110                         validate.Var(m, "required,dive,required")
111                 }
112         })
113 }
114
115 func BenchmarkFieldCustomTypeSuccess(b *testing.B) {
116
117         validate := New()
118         validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{})
119
120         val := valuer{
121                 Name: "1",
122         }
123
124         b.ResetTimer()
125         for n := 0; n < b.N; n++ {
126                 validate.Var(val, "len=1")
127         }
128 }
129
130 func BenchmarkFieldCustomTypeSuccessParallel(b *testing.B) {
131
132         validate := New()
133         validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{})
134
135         val := valuer{
136                 Name: "1",
137         }
138
139         b.ResetTimer()
140         b.RunParallel(func(pb *testing.PB) {
141                 for pb.Next() {
142                         validate.Var(val, "len=1")
143                 }
144         })
145 }
146
147 func BenchmarkFieldCustomTypeFailure(b *testing.B) {
148
149         validate := New()
150         validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{})
151
152         val := valuer{}
153
154         b.ResetTimer()
155         for n := 0; n < b.N; n++ {
156                 validate.Var(val, "len=1")
157         }
158 }
159
160 func BenchmarkFieldCustomTypeFailureParallel(b *testing.B) {
161
162         validate := New()
163         validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{})
164
165         val := valuer{}
166
167         b.ResetTimer()
168         b.RunParallel(func(pb *testing.PB) {
169                 for pb.Next() {
170                         validate.Var(val, "len=1")
171                 }
172         })
173 }
174
175 func BenchmarkFieldOrTagSuccess(b *testing.B) {
176
177         validate := New()
178
179         s := "rgba(0,0,0,1)"
180
181         b.ResetTimer()
182         for n := 0; n < b.N; n++ {
183                 validate.Var(s, "rgb|rgba")
184         }
185 }
186
187 func BenchmarkFieldOrTagSuccessParallel(b *testing.B) {
188
189         validate := New()
190
191         s := "rgba(0,0,0,1)"
192
193         b.ResetTimer()
194         b.RunParallel(func(pb *testing.PB) {
195                 for pb.Next() {
196                         validate.Var(s, "rgb|rgba")
197                 }
198         })
199 }
200
201 func BenchmarkFieldOrTagFailure(b *testing.B) {
202
203         validate := New()
204
205         s := "#000"
206
207         b.ResetTimer()
208         for n := 0; n < b.N; n++ {
209                 validate.Var(s, "rgb|rgba")
210         }
211 }
212
213 func BenchmarkFieldOrTagFailureParallel(b *testing.B) {
214
215         validate := New()
216
217         s := "#000"
218
219         b.ResetTimer()
220         b.RunParallel(func(pb *testing.PB) {
221                 for pb.Next() {
222                         validate.Var(s, "rgb|rgba")
223                 }
224         })
225 }
226
227 func BenchmarkStructLevelValidationSuccess(b *testing.B) {
228
229         validate := New()
230         validate.RegisterStructValidation(StructValidationTestStructSuccess, TestStruct{})
231
232         tst := TestStruct{
233                 String: "good value",
234         }
235
236         b.ResetTimer()
237         for n := 0; n < b.N; n++ {
238                 validate.Struct(tst)
239         }
240 }
241
242 func BenchmarkStructLevelValidationSuccessParallel(b *testing.B) {
243
244         validate := New()
245         validate.RegisterStructValidation(StructValidationTestStructSuccess, TestStruct{})
246
247         tst := TestStruct{
248                 String: "good value",
249         }
250
251         b.ResetTimer()
252         b.RunParallel(func(pb *testing.PB) {
253                 for pb.Next() {
254                         validate.Struct(tst)
255                 }
256         })
257 }
258
259 func BenchmarkStructLevelValidationFailure(b *testing.B) {
260
261         validate := New()
262         validate.RegisterStructValidation(StructValidationTestStruct, TestStruct{})
263
264         tst := TestStruct{
265                 String: "good value",
266         }
267
268         b.ResetTimer()
269         for n := 0; n < b.N; n++ {
270                 validate.Struct(tst)
271         }
272 }
273
274 func BenchmarkStructLevelValidationFailureParallel(b *testing.B) {
275
276         validate := New()
277         validate.RegisterStructValidation(StructValidationTestStruct, TestStruct{})
278
279         tst := TestStruct{
280                 String: "good value",
281         }
282
283         b.ResetTimer()
284         b.RunParallel(func(pb *testing.PB) {
285                 for pb.Next() {
286                         validate.Struct(tst)
287                 }
288         })
289 }
290
291 func BenchmarkStructSimpleCustomTypeSuccess(b *testing.B) {
292
293         validate := New()
294         validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{})
295
296         val := valuer{
297                 Name: "1",
298         }
299
300         type Foo struct {
301                 Valuer   valuer `validate:"len=1"`
302                 IntValue int    `validate:"min=5,max=10"`
303         }
304
305         validFoo := &Foo{Valuer: val, IntValue: 7}
306
307         b.ResetTimer()
308         for n := 0; n < b.N; n++ {
309                 validate.Struct(validFoo)
310         }
311 }
312
313 func BenchmarkStructSimpleCustomTypeSuccessParallel(b *testing.B) {
314
315         validate := New()
316         validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{})
317
318         val := valuer{
319                 Name: "1",
320         }
321
322         type Foo struct {
323                 Valuer   valuer `validate:"len=1"`
324                 IntValue int    `validate:"min=5,max=10"`
325         }
326
327         validFoo := &Foo{Valuer: val, IntValue: 7}
328
329         b.ResetTimer()
330         b.RunParallel(func(pb *testing.PB) {
331                 for pb.Next() {
332                         validate.Struct(validFoo)
333                 }
334         })
335 }
336
337 func BenchmarkStructSimpleCustomTypeFailure(b *testing.B) {
338
339         validate := New()
340         validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{})
341
342         val := valuer{}
343
344         type Foo struct {
345                 Valuer   valuer `validate:"len=1"`
346                 IntValue int    `validate:"min=5,max=10"`
347         }
348
349         validFoo := &Foo{Valuer: val, IntValue: 3}
350
351         b.ResetTimer()
352         for n := 0; n < b.N; n++ {
353                 validate.Struct(validFoo)
354         }
355 }
356
357 func BenchmarkStructSimpleCustomTypeFailureParallel(b *testing.B) {
358
359         validate := New()
360         validate.RegisterCustomTypeFunc(ValidateValuerType, (*sql.Valuer)(nil), valuer{})
361
362         val := valuer{}
363
364         type Foo struct {
365                 Valuer   valuer `validate:"len=1"`
366                 IntValue int    `validate:"min=5,max=10"`
367         }
368
369         validFoo := &Foo{Valuer: val, IntValue: 3}
370
371         b.ResetTimer()
372         b.RunParallel(func(pb *testing.PB) {
373                 for pb.Next() {
374                         validate.Struct(validate.Struct(validFoo))
375                 }
376         })
377 }
378
379 func BenchmarkStructFilteredSuccess(b *testing.B) {
380
381         validate := New()
382
383         type Test struct {
384                 Name     string `validate:"required"`
385                 NickName string `validate:"required"`
386         }
387
388         test := &Test{
389                 Name: "Joey Bloggs",
390         }
391
392         byts := []byte("Name")
393
394         fn := func(ns []byte) bool {
395                 return !bytes.HasSuffix(ns, byts)
396         }
397
398         b.ResetTimer()
399         for n := 0; n < b.N; n++ {
400                 validate.StructFiltered(test, fn)
401         }
402 }
403
404 func BenchmarkStructFilteredSuccessParallel(b *testing.B) {
405
406         validate := New()
407
408         type Test struct {
409                 Name     string `validate:"required"`
410                 NickName string `validate:"required"`
411         }
412
413         test := &Test{
414                 Name: "Joey Bloggs",
415         }
416
417         byts := []byte("Name")
418
419         fn := func(ns []byte) bool {
420                 return !bytes.HasSuffix(ns, byts)
421         }
422
423         b.ResetTimer()
424         b.RunParallel(func(pb *testing.PB) {
425                 for pb.Next() {
426                         validate.StructFiltered(test, fn)
427                 }
428         })
429 }
430
431 func BenchmarkStructFilteredFailure(b *testing.B) {
432
433         validate := New()
434
435         type Test struct {
436                 Name     string `validate:"required"`
437                 NickName string `validate:"required"`
438         }
439
440         test := &Test{
441                 Name: "Joey Bloggs",
442         }
443
444         byts := []byte("NickName")
445
446         fn := func(ns []byte) bool {
447                 return !bytes.HasSuffix(ns, byts)
448         }
449
450         b.ResetTimer()
451         for n := 0; n < b.N; n++ {
452                 validate.StructFiltered(test, fn)
453         }
454 }
455
456 func BenchmarkStructFilteredFailureParallel(b *testing.B) {
457
458         validate := New()
459
460         type Test struct {
461                 Name     string `validate:"required"`
462                 NickName string `validate:"required"`
463         }
464
465         test := &Test{
466                 Name: "Joey Bloggs",
467         }
468
469         byts := []byte("NickName")
470
471         fn := func(ns []byte) bool {
472                 return !bytes.HasSuffix(ns, byts)
473         }
474
475         b.ResetTimer()
476         b.RunParallel(func(pb *testing.PB) {
477                 for pb.Next() {
478                         validate.StructFiltered(test, fn)
479                 }
480         })
481 }
482
483 func BenchmarkStructPartialSuccess(b *testing.B) {
484
485         validate := New()
486
487         type Test struct {
488                 Name     string `validate:"required"`
489                 NickName string `validate:"required"`
490         }
491
492         test := &Test{
493                 Name: "Joey Bloggs",
494         }
495
496         b.ResetTimer()
497         for n := 0; n < b.N; n++ {
498                 validate.StructPartial(test, "Name")
499         }
500 }
501
502 func BenchmarkStructPartialSuccessParallel(b *testing.B) {
503
504         validate := New()
505
506         type Test struct {
507                 Name     string `validate:"required"`
508                 NickName string `validate:"required"`
509         }
510
511         test := &Test{
512                 Name: "Joey Bloggs",
513         }
514
515         b.ResetTimer()
516         b.RunParallel(func(pb *testing.PB) {
517                 for pb.Next() {
518                         validate.StructPartial(test, "Name")
519                 }
520         })
521 }
522
523 func BenchmarkStructPartialFailure(b *testing.B) {
524
525         validate := New()
526
527         type Test struct {
528                 Name     string `validate:"required"`
529                 NickName string `validate:"required"`
530         }
531
532         test := &Test{
533                 Name: "Joey Bloggs",
534         }
535
536         b.ResetTimer()
537         for n := 0; n < b.N; n++ {
538                 validate.StructPartial(test, "NickName")
539         }
540 }
541
542 func BenchmarkStructPartialFailureParallel(b *testing.B) {
543
544         validate := New()
545
546         type Test struct {
547                 Name     string `validate:"required"`
548                 NickName string `validate:"required"`
549         }
550
551         test := &Test{
552                 Name: "Joey Bloggs",
553         }
554
555         b.ResetTimer()
556         b.RunParallel(func(pb *testing.PB) {
557                 for pb.Next() {
558                         validate.StructPartial(test, "NickName")
559                 }
560         })
561 }
562
563 func BenchmarkStructExceptSuccess(b *testing.B) {
564
565         validate := New()
566
567         type Test struct {
568                 Name     string `validate:"required"`
569                 NickName string `validate:"required"`
570         }
571
572         test := &Test{
573                 Name: "Joey Bloggs",
574         }
575
576         b.ResetTimer()
577         for n := 0; n < b.N; n++ {
578                 validate.StructExcept(test, "Nickname")
579         }
580 }
581
582 func BenchmarkStructExceptSuccessParallel(b *testing.B) {
583
584         validate := New()
585
586         type Test struct {
587                 Name     string `validate:"required"`
588                 NickName string `validate:"required"`
589         }
590
591         test := &Test{
592                 Name: "Joey Bloggs",
593         }
594
595         b.ResetTimer()
596         b.RunParallel(func(pb *testing.PB) {
597                 for pb.Next() {
598                         validate.StructExcept(test, "NickName")
599                 }
600         })
601 }
602
603 func BenchmarkStructExceptFailure(b *testing.B) {
604
605         validate := New()
606
607         type Test struct {
608                 Name     string `validate:"required"`
609                 NickName string `validate:"required"`
610         }
611
612         test := &Test{
613                 Name: "Joey Bloggs",
614         }
615
616         b.ResetTimer()
617         for n := 0; n < b.N; n++ {
618                 validate.StructExcept(test, "Name")
619         }
620 }
621
622 func BenchmarkStructExceptFailureParallel(b *testing.B) {
623
624         validate := New()
625
626         type Test struct {
627                 Name     string `validate:"required"`
628                 NickName string `validate:"required"`
629         }
630
631         test := &Test{
632                 Name: "Joey Bloggs",
633         }
634
635         b.ResetTimer()
636         b.RunParallel(func(pb *testing.PB) {
637                 for pb.Next() {
638                         validate.StructExcept(test, "Name")
639                 }
640         })
641 }
642
643 func BenchmarkStructSimpleCrossFieldSuccess(b *testing.B) {
644
645         validate := New()
646
647         type Test struct {
648                 Start time.Time
649                 End   time.Time `validate:"gtfield=Start"`
650         }
651
652         now := time.Now().UTC()
653         then := now.Add(time.Hour * 5)
654
655         test := &Test{
656                 Start: now,
657                 End:   then,
658         }
659
660         b.ResetTimer()
661         for n := 0; n < b.N; n++ {
662                 validate.Struct(test)
663         }
664 }
665
666 func BenchmarkStructSimpleCrossFieldSuccessParallel(b *testing.B) {
667
668         validate := New()
669
670         type Test struct {
671                 Start time.Time
672                 End   time.Time `validate:"gtfield=Start"`
673         }
674
675         now := time.Now().UTC()
676         then := now.Add(time.Hour * 5)
677
678         test := &Test{
679                 Start: now,
680                 End:   then,
681         }
682
683         b.ResetTimer()
684         b.RunParallel(func(pb *testing.PB) {
685                 for pb.Next() {
686                         validate.Struct(test)
687                 }
688         })
689 }
690
691 func BenchmarkStructSimpleCrossFieldFailure(b *testing.B) {
692
693         validate := New()
694
695         type Test struct {
696                 Start time.Time
697                 End   time.Time `validate:"gtfield=Start"`
698         }
699
700         now := time.Now().UTC()
701         then := now.Add(time.Hour * -5)
702
703         test := &Test{
704                 Start: now,
705                 End:   then,
706         }
707
708         b.ResetTimer()
709         for n := 0; n < b.N; n++ {
710                 validate.Struct(test)
711         }
712 }
713
714 func BenchmarkStructSimpleCrossFieldFailureParallel(b *testing.B) {
715
716         validate := New()
717
718         type Test struct {
719                 Start time.Time
720                 End   time.Time `validate:"gtfield=Start"`
721         }
722
723         now := time.Now().UTC()
724         then := now.Add(time.Hour * -5)
725
726         test := &Test{
727                 Start: now,
728                 End:   then,
729         }
730         b.ResetTimer()
731         b.RunParallel(func(pb *testing.PB) {
732                 for pb.Next() {
733                         validate.Struct(test)
734                 }
735         })
736 }
737
738 func BenchmarkStructSimpleCrossStructCrossFieldSuccess(b *testing.B) {
739
740         validate := New()
741
742         type Inner struct {
743                 Start time.Time
744         }
745
746         type Outer struct {
747                 Inner     *Inner
748                 CreatedAt time.Time `validate:"eqcsfield=Inner.Start"`
749         }
750
751         now := time.Now().UTC()
752
753         inner := &Inner{
754                 Start: now,
755         }
756
757         outer := &Outer{
758                 Inner:     inner,
759                 CreatedAt: now,
760         }
761
762         b.ResetTimer()
763         for n := 0; n < b.N; n++ {
764                 validate.Struct(outer)
765         }
766 }
767
768 func BenchmarkStructSimpleCrossStructCrossFieldSuccessParallel(b *testing.B) {
769
770         validate := New()
771
772         type Inner struct {
773                 Start time.Time
774         }
775
776         type Outer struct {
777                 Inner     *Inner
778                 CreatedAt time.Time `validate:"eqcsfield=Inner.Start"`
779         }
780
781         now := time.Now().UTC()
782
783         inner := &Inner{
784                 Start: now,
785         }
786
787         outer := &Outer{
788                 Inner:     inner,
789                 CreatedAt: now,
790         }
791
792         b.ResetTimer()
793         b.RunParallel(func(pb *testing.PB) {
794                 for pb.Next() {
795                         validate.Struct(outer)
796                 }
797         })
798 }
799
800 func BenchmarkStructSimpleCrossStructCrossFieldFailure(b *testing.B) {
801
802         validate := New()
803
804         type Inner struct {
805                 Start time.Time
806         }
807
808         type Outer struct {
809                 Inner     *Inner
810                 CreatedAt time.Time `validate:"eqcsfield=Inner.Start"`
811         }
812
813         now := time.Now().UTC()
814         then := now.Add(time.Hour * 5)
815
816         inner := &Inner{
817                 Start: then,
818         }
819
820         outer := &Outer{
821                 Inner:     inner,
822                 CreatedAt: now,
823         }
824
825         b.ResetTimer()
826         for n := 0; n < b.N; n++ {
827                 validate.Struct(outer)
828         }
829 }
830
831 func BenchmarkStructSimpleCrossStructCrossFieldFailureParallel(b *testing.B) {
832
833         validate := New()
834
835         type Inner struct {
836                 Start time.Time
837         }
838
839         type Outer struct {
840                 Inner     *Inner
841                 CreatedAt time.Time `validate:"eqcsfield=Inner.Start"`
842         }
843
844         now := time.Now().UTC()
845         then := now.Add(time.Hour * 5)
846
847         inner := &Inner{
848                 Start: then,
849         }
850
851         outer := &Outer{
852                 Inner:     inner,
853                 CreatedAt: now,
854         }
855
856         b.ResetTimer()
857         b.RunParallel(func(pb *testing.PB) {
858                 for pb.Next() {
859                         validate.Struct(outer)
860                 }
861         })
862 }
863
864 func BenchmarkStructSimpleSuccess(b *testing.B) {
865
866         validate := New()
867
868         type Foo struct {
869                 StringValue string `validate:"min=5,max=10"`
870                 IntValue    int    `validate:"min=5,max=10"`
871         }
872
873         validFoo := &Foo{StringValue: "Foobar", IntValue: 7}
874
875         b.ResetTimer()
876         for n := 0; n < b.N; n++ {
877                 validate.Struct(validFoo)
878         }
879 }
880
881 func BenchmarkStructSimpleSuccessParallel(b *testing.B) {
882
883         validate := New()
884
885         type Foo struct {
886                 StringValue string `validate:"min=5,max=10"`
887                 IntValue    int    `validate:"min=5,max=10"`
888         }
889
890         validFoo := &Foo{StringValue: "Foobar", IntValue: 7}
891
892         b.ResetTimer()
893         b.RunParallel(func(pb *testing.PB) {
894                 for pb.Next() {
895                         validate.Struct(validFoo)
896                 }
897         })
898 }
899
900 func BenchmarkStructSimpleFailure(b *testing.B) {
901
902         validate := New()
903
904         type Foo struct {
905                 StringValue string `validate:"min=5,max=10"`
906                 IntValue    int    `validate:"min=5,max=10"`
907         }
908
909         invalidFoo := &Foo{StringValue: "Fo", IntValue: 3}
910
911         b.ResetTimer()
912         for n := 0; n < b.N; n++ {
913                 validate.Struct(invalidFoo)
914         }
915 }
916
917 func BenchmarkStructSimpleFailureParallel(b *testing.B) {
918
919         validate := New()
920
921         type Foo struct {
922                 StringValue string `validate:"min=5,max=10"`
923                 IntValue    int    `validate:"min=5,max=10"`
924         }
925
926         invalidFoo := &Foo{StringValue: "Fo", IntValue: 3}
927
928         b.ResetTimer()
929         b.RunParallel(func(pb *testing.PB) {
930                 for pb.Next() {
931                         validate.Struct(invalidFoo)
932                 }
933         })
934 }
935
936 func BenchmarkStructComplexSuccess(b *testing.B) {
937
938         validate := New()
939
940         tSuccess := &TestString{
941                 Required:  "Required",
942                 Len:       "length==10",
943                 Min:       "min=1",
944                 Max:       "1234567890",
945                 MinMax:    "12345",
946                 Lt:        "012345678",
947                 Lte:       "0123456789",
948                 Gt:        "01234567890",
949                 Gte:       "0123456789",
950                 OmitEmpty: "",
951                 Sub: &SubTest{
952                         Test: "1",
953                 },
954                 SubIgnore: &SubTest{
955                         Test: "",
956                 },
957                 Anonymous: struct {
958                         A string `validate:"required"`
959                 }{
960                         A: "1",
961                 },
962                 Iface: &Impl{
963                         F: "123",
964                 },
965         }
966
967         b.ResetTimer()
968         for n := 0; n < b.N; n++ {
969                 validate.Struct(tSuccess)
970         }
971 }
972
973 func BenchmarkStructComplexSuccessParallel(b *testing.B) {
974
975         validate := New()
976
977         tSuccess := &TestString{
978                 Required:  "Required",
979                 Len:       "length==10",
980                 Min:       "min=1",
981                 Max:       "1234567890",
982                 MinMax:    "12345",
983                 Lt:        "012345678",
984                 Lte:       "0123456789",
985                 Gt:        "01234567890",
986                 Gte:       "0123456789",
987                 OmitEmpty: "",
988                 Sub: &SubTest{
989                         Test: "1",
990                 },
991                 SubIgnore: &SubTest{
992                         Test: "",
993                 },
994                 Anonymous: struct {
995                         A string `validate:"required"`
996                 }{
997                         A: "1",
998                 },
999                 Iface: &Impl{
1000                         F: "123",
1001                 },
1002         }
1003
1004         b.ResetTimer()
1005         b.RunParallel(func(pb *testing.PB) {
1006                 for pb.Next() {
1007                         validate.Struct(tSuccess)
1008                 }
1009         })
1010 }
1011
1012 func BenchmarkStructComplexFailure(b *testing.B) {
1013
1014         validate := New()
1015
1016         tFail := &TestString{
1017                 Required:  "",
1018                 Len:       "",
1019                 Min:       "",
1020                 Max:       "12345678901",
1021                 MinMax:    "",
1022                 Lt:        "0123456789",
1023                 Lte:       "01234567890",
1024                 Gt:        "1",
1025                 Gte:       "1",
1026                 OmitEmpty: "12345678901",
1027                 Sub: &SubTest{
1028                         Test: "",
1029                 },
1030                 Anonymous: struct {
1031                         A string `validate:"required"`
1032                 }{
1033                         A: "",
1034                 },
1035                 Iface: &Impl{
1036                         F: "12",
1037                 },
1038         }
1039
1040         b.ResetTimer()
1041         for n := 0; n < b.N; n++ {
1042                 validate.Struct(tFail)
1043         }
1044 }
1045
1046 func BenchmarkStructComplexFailureParallel(b *testing.B) {
1047
1048         validate := New()
1049
1050         tFail := &TestString{
1051                 Required:  "",
1052                 Len:       "",
1053                 Min:       "",
1054                 Max:       "12345678901",
1055                 MinMax:    "",
1056                 Lt:        "0123456789",
1057                 Lte:       "01234567890",
1058                 Gt:        "1",
1059                 Gte:       "1",
1060                 OmitEmpty: "12345678901",
1061                 Sub: &SubTest{
1062                         Test: "",
1063                 },
1064                 Anonymous: struct {
1065                         A string `validate:"required"`
1066                 }{
1067                         A: "",
1068                 },
1069                 Iface: &Impl{
1070                         F: "12",
1071                 },
1072         }
1073
1074         b.ResetTimer()
1075         b.RunParallel(func(pb *testing.PB) {
1076                 for pb.Next() {
1077                         validate.Struct(tFail)
1078                 }
1079         })
1080 }