From 81ce302975642be612f20717304827de38bebb55 Mon Sep 17 00:00:00 2001 From: joeybloggs Date: Sun, 7 Jun 2015 23:54:06 -0400 Subject: [PATCH] add parallel benchmark --- validator_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/validator_test.go b/validator_test.go index 9a71573..aed06a9 100644 --- a/validator_test.go +++ b/validator_test.go @@ -2377,3 +2377,21 @@ func BenchmarkValidateStruct(b *testing.B) { validate.Struct(invalidFoo) } } + +func BenchmarkTemplateParallel(b *testing.B) { + + type Foo struct { + StringValue string `validate:"min=5,max=10"` + IntValue int `validate:"min=5,max=10"` + } + + validFoo := &Foo{StringValue: "Foobar", IntValue: 7} + invalidFoo := &Foo{StringValue: "Fo", IntValue: 3} + + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + validate.Struct(validFoo) + validate.Struct(invalidFoo) + } + }) +}