close the pool after testing

This commit is contained in:
andy pan 2018-07-02 14:26:17 +08:00
parent 71521b2044
commit 926f57c696
2 changed files with 4 additions and 0 deletions

View File

@ -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++ {

View File

@ -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)