mirror of https://github.com/panjf2000/ants.git
Merge branch 'develop'
This commit is contained in:
commit
62bb200a60
|
@ -171,7 +171,7 @@ There was only the test of `ants` Pool because my computer was crash when it rea
|
||||||
|
|
||||||
**As you can see, `ants` can up to 2x~6x faster than goroutines without pool and the memory consumption is reduced by 10 to 20 times.**
|
**As you can see, `ants` can up to 2x~6x faster than goroutines without pool and the memory consumption is reduced by 10 to 20 times.**
|
||||||
|
|
||||||
[1]: https://travis-ci.com/panjf2000/ants.svg?branch=master
|
[1]: https://travis-ci.com/panjf2000/ants.svg?branch=develop
|
||||||
[2]: https://travis-ci.com/panjf2000/ants
|
[2]: https://travis-ci.com/panjf2000/ants
|
||||||
[3]: https://godoc.org/github.com/panjf2000/ants?status.svg
|
[3]: https://godoc.org/github.com/panjf2000/ants?status.svg
|
||||||
[4]: https://godoc.org/github.com/panjf2000/ants
|
[4]: https://godoc.org/github.com/panjf2000/ants
|
||||||
|
|
|
@ -77,6 +77,7 @@ func BenchmarkGoroutineWithFunc(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkAntsPoolWithFunc(b *testing.B) {
|
func BenchmarkAntsPoolWithFunc(b *testing.B) {
|
||||||
|
defer ants.Release()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
p, _ := ants.NewPoolWithFunc(50000, func(i interface{}) error {
|
p, _ := ants.NewPoolWithFunc(50000, func(i interface{}) error {
|
||||||
demoPoolFunc(i)
|
demoPoolFunc(i)
|
||||||
|
@ -103,6 +104,8 @@ func BenchmarkGoroutine(b *testing.B) {
|
||||||
|
|
||||||
func BenchmarkAntsPool(b *testing.B) {
|
func BenchmarkAntsPool(b *testing.B) {
|
||||||
p, _ := ants.NewPoolWithFunc(50000, demoPoolFunc)
|
p, _ := ants.NewPoolWithFunc(50000, demoPoolFunc)
|
||||||
|
p.Release()
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
for j := 0; j < RunTimes; j++ {
|
for j := 0; j < RunTimes; j++ {
|
||||||
|
|
|
@ -54,6 +54,7 @@ func TestDefaultPool(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoPool(t *testing.T) {
|
func TestNoPool(t *testing.T) {
|
||||||
|
defer ants.Release()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
Loading…
Reference in New Issue