From 32d4903f957ead284e044a1ac6417732a5932fc8 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Sat, 21 Jul 2018 19:34:15 +0800 Subject: [PATCH] add more test --- ants_benchmark_test.go | 1 + ants_test.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ants_benchmark_test.go b/ants_benchmark_test.go index 0374d8a..56d94f7 100644 --- a/ants_benchmark_test.go +++ b/ants_benchmark_test.go @@ -45,6 +45,7 @@ const ( RunTimes = 10000000 Param = 100 AntsSize = 500 + TestSize = 10000 ) func demoFunc() error { diff --git a/ants_test.go b/ants_test.go index 908f414..80cf140 100644 --- a/ants_test.go +++ b/ants_test.go @@ -28,6 +28,7 @@ import ( "testing" "github.com/panjf2000/ants" + "time" ) var n = 100000 @@ -46,7 +47,6 @@ func TestAntsPoolWithFunc(t *testing.T) { p.Serve(Param) } wg.Wait() - t.Logf("pool with func, running workers number:%d", p.Running()) mem := runtime.MemStats{} runtime.ReadMemStats(&mem) @@ -114,17 +114,18 @@ func TestCodeCov(t *testing.T) { p0.ReSize(AntsSize / 2) t.Logf("pool, after resize, capacity:%d, running:%d", p0.Cap(), p0.Running()) - p, _ := ants.NewPoolWithFunc(AntsSize, demoPoolFunc) + p, _ := ants.NewPoolWithFunc(TestSize, demoPoolFunc) defer p.Serve(Param) defer p.Release() for i := 0; i < n; i++ { p.Serve(Param) } + time.Sleep(ants.DefaultCleanIntervalTime * time.Second) t.Logf("pool with func, capacity:%d", p.Cap()) t.Logf("pool with func, running workers number:%d", p.Running()) t.Logf("pool with func, free workers number:%d", p.Free()) + p.ReSize(TestSize) p.ReSize(AntsSize) - p.ReSize(AntsSize / 2) t.Logf("pool with func, after resize, capacity:%d, running:%d", p.Cap(), p.Running()) }