From 686f5d2cd218e1c8bc55575af4e6861404ce292c Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sat, 30 Dec 2017 01:05:39 -0200 Subject: [PATCH] test: added benchmark as well --- internal/handler/handler_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/handler/handler_test.go b/internal/handler/handler_test.go index 97fde652c..0f8c8361f 100644 --- a/internal/handler/handler_test.go +++ b/internal/handler/handler_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/stretchr/testify/assert" + "golang.org/x/sync/errgroup" ) func TestHandlerOK(t *testing.T) { @@ -54,3 +55,18 @@ func TestHandlerSignals(t *testing.T) { }) } } + +func BenchmarkHandler(b *testing.B) { + var task Task = func() error { + return nil + } + var h = New() + var ctx = context.Background() + var wg errgroup.Group + for i := 0; i < 10000; i++ { + wg.Go(func() error { + return h.Run(ctx, task) + }) + } + assert.NoError(b, wg.Wait()) +}