tplimpl: Make partial benchmarks use RunParallel
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 16 Nov 2017 00:13:07 +0000 (01:13 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 16 Nov 2017 00:13:07 +0000 (01:13 +0100)
See #4086

tpl/tplimpl/template_funcs_test.go

index 546effdf349d2bb59344cb2385016361beb71077..32f1a1a719400966caceef1ae470f8e47967efc6 100644 (file)
@@ -194,11 +194,13 @@ func doBenchmarkPartial(b *testing.B, f func(ns *partials.Namespace) error) {
        ns := partials.New(de)
 
        b.ResetTimer()
-       for i := 0; i < b.N; i++ {
-               if err := f(ns); err != nil {
-                       b.Fatalf("error executing template: %s", err)
+       b.RunParallel(func(pb *testing.PB) {
+               for pb.Next() {
+                       if err := f(ns); err != nil {
+                               b.Fatalf("error executing template: %s", err)
+                       }
                }
-       }
+       })
 }
 
 func newTestFuncster() *templateFuncster {