forked from mirror/ants
close the pool after testing
This commit is contained in:
parent
71521b2044
commit
926f57c696
|
@ -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