forked from mirror/ants
update
This commit is contained in:
parent
2e3a9a650e
commit
ea5025d8ab
38
ants_test.go
38
ants_test.go
|
@ -73,7 +73,7 @@ func TestDefaultPool(t *testing.T) {
|
|||
t.Logf("running workers number:%d", ants.Running())
|
||||
mem := runtime.MemStats{}
|
||||
runtime.ReadMemStats(&mem)
|
||||
t.Logf("memory usage:%d", mem.TotalAlloc/MiB)
|
||||
t.Logf("memory usage:%d MB", mem.TotalAlloc/MiB)
|
||||
}
|
||||
|
||||
func TestNoPool(t *testing.T) {
|
||||
|
@ -89,30 +89,30 @@ func TestNoPool(t *testing.T) {
|
|||
wg.Wait()
|
||||
mem := runtime.MemStats{}
|
||||
runtime.ReadMemStats(&mem)
|
||||
t.Logf("memory usage:%d", mem.TotalAlloc/MiB)
|
||||
t.Logf("memory usage:%d MB", mem.TotalAlloc/MiB)
|
||||
}
|
||||
|
||||
func TestAntsPoolWithFunc(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
p, _ := ants.NewPoolWithFunc(50000, func(i interface{}) error {
|
||||
demoPoolFunc(i)
|
||||
wg.Done()
|
||||
return nil
|
||||
})
|
||||
for i := 0; i < n; i++ {
|
||||
wg.Add(1)
|
||||
p.Serve(n)
|
||||
}
|
||||
wg.Wait()
|
||||
//func TestAntsPoolWithFunc(t *testing.T) {
|
||||
// var wg sync.WaitGroup
|
||||
// p, _ := ants.NewPoolWithFunc(50000, func(i interface{}) error {
|
||||
// demoPoolFunc(i)
|
||||
// wg.Done()
|
||||
// return nil
|
||||
// })
|
||||
// for i := 0; i < n; i++ {
|
||||
// wg.Add(1)
|
||||
// p.Serve(n)
|
||||
// }
|
||||
// wg.Wait()
|
||||
|
||||
//t.Logf("pool capacity:%d", ants.Cap())
|
||||
//t.Logf("free workers number:%d", ants.Free())
|
||||
|
||||
t.Logf("running workers number:%d", p.Running())
|
||||
mem := runtime.MemStats{}
|
||||
runtime.ReadMemStats(&mem)
|
||||
t.Logf("memory usage:%d", mem.TotalAlloc/GiB)
|
||||
}
|
||||
// t.Logf("running workers number:%d", p.Running())
|
||||
// mem := runtime.MemStats{}
|
||||
// runtime.ReadMemStats(&mem)
|
||||
// t.Logf("memory usage:%d", mem.TotalAlloc/GiB)
|
||||
//}
|
||||
|
||||
// func TestNoPool(t *testing.T) {
|
||||
// var wg sync.WaitGroup
|
||||
|
|
Loading…
Reference in New Issue