mirror of https://github.com/panjf2000/ants.git
update benchmark test code
This commit is contained in:
parent
affcb8eaf7
commit
b6f91756ab
|
@ -63,8 +63,8 @@ func demoPoolFunc(args interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkGoroutineWithFunc(b *testing.B) {
|
func BenchmarkGoroutineWithFunc(b *testing.B) {
|
||||||
|
var wg sync.WaitGroup
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
var wg sync.WaitGroup
|
|
||||||
for j := 0; j < RunTimes; j++ {
|
for j := 0; j < RunTimes; j++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -77,13 +77,13 @@ func BenchmarkGoroutineWithFunc(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkAntsPoolWithFunc(b *testing.B) {
|
func BenchmarkAntsPoolWithFunc(b *testing.B) {
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
p, _ := ants.NewPoolWithFunc(50000, func(i interface{}) error {
|
||||||
|
demoPoolFunc(i)
|
||||||
|
wg.Done()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
var wg sync.WaitGroup
|
|
||||||
p, _ := ants.NewPoolWithFunc(50000, func(i interface{}) error {
|
|
||||||
demoPoolFunc(i)
|
|
||||||
wg.Done()
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
for j := 0; j < RunTimes; j++ {
|
for j := 0; j < RunTimes; j++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
p.Serve(loop)
|
p.Serve(loop)
|
||||||
|
|
Loading…
Reference in New Issue