20 lines
296 B
Go
20 lines
296 B
Go
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()
|
|
}
|
|
}
|