forked from mirror/ants
update codecov test
This commit is contained in:
parent
9da43e1115
commit
9b4f9c7b48
15
README.md
15
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
|
||||
|
|
|
@ -44,7 +44,7 @@ const (
|
|||
const (
|
||||
RunTimes = 10000000
|
||||
Param = 10
|
||||
AntsSize = 100000
|
||||
AntsSize = 50000
|
||||
)
|
||||
|
||||
func demoFunc() error {
|
||||
|
|
17
ants_test.go
17
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())
|
||||
}
|
||||
|
|
3
pool.go
3
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()
|
||||
})
|
||||
|
|
|
@ -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()
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue