From 9b4f9c7b48aab86d5e454515fe060f135661f02f Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Sun, 15 Jul 2018 22:45:55 +0800 Subject: [PATCH] update codecov test --- README.md | 15 +++++++++------ ants_benchmark_test.go | 2 +- ants_test.go | 17 +++++++++++++++++ pool.go | 3 --- pool_func.go | 3 --- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 85d91fa..4a00b99 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,10 @@ [![Build Status][1]][2] -[![godoc for panjf2000/ants][3]][4] +[![codecov][3]][4] [![goreportcard for panjf2000/ants][5]][6] -[![MIT Licence][7]][8] +[![godoc for panjf2000/ants][7]][8] +[![MIT Licence][9]][10] [中文项目说明](README_ZH.md) | [Project Tutorial](http://blog.taohuawu.club/article/42) @@ -185,9 +186,11 @@ There was only the test of `ants` Pool because my computer was crash when it rea [1]: https://travis-ci.com/panjf2000/ants.svg?branch=develop [2]: https://travis-ci.com/panjf2000/ants -[3]: https://godoc.org/github.com/panjf2000/ants?status.svg -[4]: https://godoc.org/github.com/panjf2000/ants +[3]: https://codecov.io/gh/panjf2000/ants +[4]: https://codecov.io/gh/panjf2000/ants/branch/develop/graph/badge.svg [5]: https://goreportcard.com/badge/github.com/panjf2000/ants [6]: https://goreportcard.com/report/github.com/panjf2000/ants -[7]: https://badges.frapsoft.com/os/mit/mit.svg?v=103 -[8]: https://opensource.org/licenses/mit-license.php +[7]: https://godoc.org/github.com/panjf2000/ants?status.svg +[8]: https://godoc.org/github.com/panjf2000/ants +[9]: https://badges.frapsoft.com/os/mit/mit.svg?v=103 +[10]: https://opensource.org/licenses/mit-license.php diff --git a/ants_benchmark_test.go b/ants_benchmark_test.go index c8623aa..440a3c8 100644 --- a/ants_benchmark_test.go +++ b/ants_benchmark_test.go @@ -44,7 +44,7 @@ const ( const ( RunTimes = 10000000 Param = 10 - AntsSize = 100000 + AntsSize = 50000 ) func demoFunc() error { diff --git a/ants_test.go b/ants_test.go index 18b5ffb..72250b4 100644 --- a/ants_test.go +++ b/ants_test.go @@ -65,6 +65,10 @@ func TestAntsPool(t *testing.T) { } wg.Wait() + t.Logf("pool, capacity:%d", ants.Cap()) + t.Logf("pool, running workers number:%d", ants.Running()) + t.Logf("pool, free workers number:%d", ants.Free()) + mem := runtime.MemStats{} runtime.ReadMemStats(&mem) t.Logf("memory usage:%d MB", mem.TotalAlloc/MiB) @@ -87,7 +91,17 @@ func TestNoPool(t *testing.T) { } func TestCodeCov(t *testing.T) { + _, err := ants.NewTimingPool(-1, -1) + t.Log(err) + _, err = ants.NewTimingPool(1, -1) + t.Log(err) + _, err = ants.NewTimingPoolWithFunc(-1, -1, demoPoolFunc) + t.Log(err) + _, err = ants.NewTimingPoolWithFunc(1, -1, demoPoolFunc) + t.Log(err) + p0, _ := ants.NewPool(AntsSize) + defer p0.Submit(demoFunc) defer p0.Release() for i := 0; i < n; i++ { p0.Submit(demoFunc) @@ -95,10 +109,12 @@ func TestCodeCov(t *testing.T) { t.Logf("pool, capacity:%d", p0.Cap()) t.Logf("pool, running workers number:%d", p0.Running()) t.Logf("pool, free workers number:%d", p0.Free()) + p0.ReSize(AntsSize) p0.ReSize(AntsSize / 2) t.Logf("pool, after resize, capacity:%d", p0.Cap()) p, _ := ants.NewPoolWithFunc(AntsSize, demoPoolFunc) + defer p.Serve(Param) defer p.Release() for i := 0; i < n; i++ { p.Serve(Param) @@ -106,6 +122,7 @@ func TestCodeCov(t *testing.T) { 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(AntsSize) p.ReSize(AntsSize / 2) t.Logf("pool with func, after resize, capacity:%d", p.Cap()) } diff --git a/pool.go b/pool.go index c832c9b..3f988aa 100644 --- a/pool.go +++ b/pool.go @@ -146,9 +146,6 @@ func (p *Pool) Release() error { p.getWorker().task <- nil } p.lock.Lock() - for i := range p.workers { - p.workers[i] = nil - } p.workers = nil p.lock.Unlock() }) diff --git a/pool_func.go b/pool_func.go index 7040f83..c4dea88 100644 --- a/pool_func.go +++ b/pool_func.go @@ -151,9 +151,6 @@ func (p *PoolWithFunc) Release() error { p.getWorker().args <- nil } p.lock.Lock() - for i := range p.workers { - p.workers[i] = nil - } p.workers = nil p.lock.Unlock() })