Add dynamic worker pool with bounded queue and concurrency tests
This commit is contained in:
19
pool_bench_test.go
Normal file
19
pool_bench_test.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package worker
|
||||
|
||||
import "testing"
|
||||
|
||||
func BenchmarkQueueRingSteady(b *testing.B) {
|
||||
p, err := New(0, 6)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
task := func() {}
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
p.mu.Lock()
|
||||
p.enqueueLocked(task)
|
||||
p.dequeueLocked()
|
||||
p.mu.Unlock()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user