MCPcopy Create free account
hub / github.com/Soypete/Production-Go-Examples / benchmarkWorkers

Function benchmarkWorkers

exercise-3/solution/worker_test.go:13–24  ·  view source on GitHub ↗
(i int, b *testing.B)

Source from the content-addressed store, hash-verified

11func Benchmark20Workers(b *testing.B) { benchmarkWorkers(20, b) }
12
13func benchmarkWorkers(i int, b *testing.B) {
14 for n := 0; n < b.N; n++ {
15 workerPool := &workerPool{
16 wg: new(sync.WaitGroup),
17 msgs: make(chan string),
18 numWorkers: i,
19 mu: new(sync.Mutex),
20 }
21 go workerPool.queueMessages()
22 _ = workerPool.run()
23 }
24}

Callers 4

Benchmark2WorkersFunction · 0.70
Benchmark5WorkersFunction · 0.70
Benchmark10WorkersFunction · 0.70
Benchmark20WorkersFunction · 0.70

Calls 2

queueMessagesMethod · 0.95
runMethod · 0.95

Tested by

no test coverage detected