From 926f57c6968b0b830ccad356191558bd7a4a0408 Mon Sep 17 00:00:00 2001 From: andy pan Date: Mon, 2 Jul 2018 14:26:17 +0800 Subject: [PATCH] close the pool after testing --- ants_benchmark_test.go | 3 +++ ants_test.go | 1 + 2 files changed, 4 insertions(+) diff --git a/ants_benchmark_test.go b/ants_benchmark_test.go index 3668e0d..0c7728d 100644 --- a/ants_benchmark_test.go +++ b/ants_benchmark_test.go @@ -77,6 +77,7 @@ func BenchmarkGoroutineWithFunc(b *testing.B) { } func BenchmarkAntsPoolWithFunc(b *testing.B) { + defer ants.Release() var wg sync.WaitGroup p, _ := ants.NewPoolWithFunc(50000, func(i interface{}) error { demoPoolFunc(i) @@ -103,6 +104,8 @@ func BenchmarkGoroutine(b *testing.B) { func BenchmarkAntsPool(b *testing.B) { p, _ := ants.NewPoolWithFunc(50000, demoPoolFunc) + p.Release() + b.ResetTimer() for i := 0; i < b.N; i++ { for j := 0; j < RunTimes; j++ { diff --git a/ants_test.go b/ants_test.go index 2334e42..0e1bc26 100644 --- a/ants_test.go +++ b/ants_test.go @@ -54,6 +54,7 @@ func TestDefaultPool(t *testing.T) { } func TestNoPool(t *testing.T) { + defer ants.Release() var wg sync.WaitGroup for i := 0; i < n; i++ { wg.Add(1)