diff options
Diffstat (limited to 'vendor/gopkg.in/go-playground/validator.v9/benchmarks_test.go')
-rw-r--r-- | vendor/gopkg.in/go-playground/validator.v9/benchmarks_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/gopkg.in/go-playground/validator.v9/benchmarks_test.go b/vendor/gopkg.in/go-playground/validator.v9/benchmarks_test.go index 3e7e79f..5ac871f 100644 --- a/vendor/gopkg.in/go-playground/validator.v9/benchmarks_test.go +++ b/vendor/gopkg.in/go-playground/validator.v9/benchmarks_test.go @@ -1184,3 +1184,27 @@ func BenchmarkStructComplexFailureParallel(b *testing.B) { } }) } + +type TestOneof struct { + Color string `validate:"oneof=red green"` +} + +func BenchmarkOneof(b *testing.B) { + w := &TestOneof{Color: "green"} + val := New() + for i := 0; i < b.N; i++ { + val.Struct(w) + } +} + +func BenchmarkOneofParallel(b *testing.B) { + w := &TestOneof{Color: "green"} + val := New() + + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + val.Struct(w) + } + }) +} |