From fd4282dc8b76685d117ddeb7006aa51cf7867b08 Mon Sep 17 00:00:00 2001 From: Oleg Zaytsev Date: Thu, 16 Jul 2020 08:33:09 +0200 Subject: [PATCH] Change benchmark to measure Worker() and Stop() This benchmark was written when the creation of goroutines was synchronous, that's not the case anymore so in order to measure _something_ we'll measure a worker acquire and Stop. --- runner_pool_bench_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/runner_pool_bench_test.go b/runner_pool_bench_test.go index f77d7eb..e07bb69 100644 --- a/runner_pool_bench_test.go +++ b/runner_pool_bench_test.go @@ -12,11 +12,14 @@ func BenchmarkCreatePool(b *testing.B) { for i := 0; i < b.N; i++ { cfg := Config{Workers: n} pool := New(cfg, goRunner) - err := pool.Start() - _ = err - b.StopTimer() + _ = pool.Start() + w, err := pool.Worker(context.Background()) + if err != nil { + panic(err) + } + w.Release() + _ = pool.Stop(context.Background()) - b.StartTimer() } }) }