From b6f91756ab438604165461fc4b735bc729ff1f63 Mon Sep 17 00:00:00 2001 From: andy pan Date: Thu, 7 Jun 2018 14:12:47 +0800 Subject: [PATCH] update benchmark test code --- ants_benchmark_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ants_benchmark_test.go b/ants_benchmark_test.go index 7399b39..003cd6b 100644 --- a/ants_benchmark_test.go +++ b/ants_benchmark_test.go @@ -63,8 +63,8 @@ func demoPoolFunc(args interface{}) error { } func BenchmarkGoroutineWithFunc(b *testing.B) { + var wg sync.WaitGroup for i := 0; i < b.N; i++ { - var wg sync.WaitGroup for j := 0; j < RunTimes; j++ { wg.Add(1) go func() { @@ -77,13 +77,13 @@ func BenchmarkGoroutineWithFunc(b *testing.B) { } func BenchmarkAntsPoolWithFunc(b *testing.B) { + var wg sync.WaitGroup + p, _ := ants.NewPoolWithFunc(50000, func(i interface{}) error { + demoPoolFunc(i) + wg.Done() + return nil + }) for i := 0; i < b.N; i++ { - var wg sync.WaitGroup - p, _ := ants.NewPoolWithFunc(50000, func(i interface{}) error { - demoPoolFunc(i) - wg.Done() - return nil - }) for j := 0; j < RunTimes; j++ { wg.Add(1) p.Serve(loop)