Adjust benchmark params

This commit is contained in:
alitto
2020-03-29 12:04:55 -03:00
parent 98e553d83c
commit a83994bd29
3 changed files with 5 additions and 39 deletions
+2 -38
View File
@@ -12,8 +12,8 @@ import (
const (
taskCount = 1000000
taskDuration = 1 * time.Millisecond
workerCount = 20000
taskDuration = 10 * time.Millisecond
workerCount = 200000
)
func testFunc() {
@@ -40,42 +40,6 @@ func BenchmarkPond(b *testing.B) {
b.StopTimer()
}
func BenchmarkPondMinWorkers(b *testing.B) {
var wg sync.WaitGroup
pool := pond.New(workerCount, taskCount, pond.MinWorkers(workerCount))
defer pool.StopAndWait()
// Submit tasks
b.ResetTimer()
for i := 0; i < b.N; i++ {
wg.Add(taskCount)
for i := 0; i < taskCount; i++ {
pool.Submit(func() {
testFunc()
wg.Done()
})
}
wg.Wait()
}
b.StopTimer()
}
func BenchmarkPondGroup(b *testing.B) {
pool := pond.New(workerCount, taskCount)
defer pool.StopAndWait()
// Submit tasks
b.ResetTimer()
for i := 0; i < b.N; i++ {
group := pool.Group()
for i := 0; i < taskCount; i++ {
group.Submit(testFunc)
}
group.Wait()
}
b.StopTimer()
}
func BenchmarkGoroutines(b *testing.B) {
var wg sync.WaitGroup
+1 -1
View File
@@ -3,7 +3,7 @@ module github.com/alitto/pond/benchmark
go 1.14
require (
github.com/alitto/pond v0.0.0-20200328140845-2664f1bbde39
github.com/alitto/pond v1.0.0
github.com/gammazero/workerpool v0.0.0-20200311205957-7b00833861c6
github.com/panjf2000/ants/v2 v2.3.1
)
+2
View File
@@ -1,5 +1,7 @@
github.com/alitto/pond v0.0.0-20200328140845-2664f1bbde39 h1:SIo+wt6R2/Kr95aTdvNuu4ByPknfHbJPfGbJMoi85q4=
github.com/alitto/pond v0.0.0-20200328140845-2664f1bbde39/go.mod h1:EDWzkjFhFR5/owRwSl7DXKa2yuSQmPB0g6C/YZSAxCo=
github.com/alitto/pond v1.0.0 h1:S6ooziYolk+z5dxct9BMpEEHkJEL3OUeNplu/NK8Si4=
github.com/alitto/pond v1.0.0/go.mod h1:VkhnWZhFBtkzZgpjXEyQ4Skyf8nfcGXsZ7PTklN29a4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=