Skip to content

Commit 81ce302

Browse files
joeybloggsjoeybloggs
authored andcommitted
add parallel benchmark
1 parent ad39bb9 commit 81ce302

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

validator_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,3 +2377,21 @@ func BenchmarkValidateStruct(b *testing.B) {
23772377
validate.Struct(invalidFoo)
23782378
}
23792379
}
2380+
2381+
func BenchmarkTemplateParallel(b *testing.B) {
2382+
2383+
type Foo struct {
2384+
StringValue string `validate:"min=5,max=10"`
2385+
IntValue int `validate:"min=5,max=10"`
2386+
}
2387+
2388+
validFoo := &Foo{StringValue: "Foobar", IntValue: 7}
2389+
invalidFoo := &Foo{StringValue: "Fo", IntValue: 3}
2390+
2391+
b.RunParallel(func(pb *testing.PB) {
2392+
for pb.Next() {
2393+
validate.Struct(validFoo)
2394+
validate.Struct(invalidFoo)
2395+
}
2396+
})
2397+
}

0 commit comments

Comments
 (0)