Loading tickets/tickets_test.go +5 −5 Original line number Diff line number Diff line Loading @@ -54,8 +54,8 @@ func TestTicketsComplex(t *testing.T) { ID, Count int } maxTickets := 200 numWorkers := runtime.NumCPU() maxTickets := 500 numWorkers := runtime.NumCPU() * 2 numBuffered := 50 // 0 for an unbuffered channel t.Logf("number of tickets: %d", maxTickets) Loading @@ -81,9 +81,9 @@ func TestTicketsComplex(t *testing.T) { }(maxTickets) // dispatch work to distinct goroutines workerResultStreamArray := make([]chan WorkerResult, numWorkers) workerResultStreamArray := make([]<-chan WorkerResult, numWorkers) for workerIndex := 0; workerIndex < numWorkers; workerIndex++ { workerResultStreamArray[workerIndex] = func(id int, ticketStream chan *Ticket) chan WorkerResult { workerResultStreamArray[workerIndex] = func(id int, ticketStream <-chan *Ticket) <-chan WorkerResult { workerResultStream := make(chan WorkerResult) count := 0 Loading Loading @@ -123,7 +123,7 @@ func TestTicketsComplex(t *testing.T) { t.Logf("worker %d processed %d", i.ID, i.Count) processedTickets += i.Count } t.Logf("processed tickets: %d - process duration: %s", processedTickets, totalProcessDuration.String()) t.Logf("processed tickets: %d - total process duration: %s", processedTickets, totalProcessDuration.String()) if maxTickets != processedTickets { t.Errorf("the count of processed tickets is %d, expected %d", processedTickets, maxTickets) } Loading Loading
tickets/tickets_test.go +5 −5 Original line number Diff line number Diff line Loading @@ -54,8 +54,8 @@ func TestTicketsComplex(t *testing.T) { ID, Count int } maxTickets := 200 numWorkers := runtime.NumCPU() maxTickets := 500 numWorkers := runtime.NumCPU() * 2 numBuffered := 50 // 0 for an unbuffered channel t.Logf("number of tickets: %d", maxTickets) Loading @@ -81,9 +81,9 @@ func TestTicketsComplex(t *testing.T) { }(maxTickets) // dispatch work to distinct goroutines workerResultStreamArray := make([]chan WorkerResult, numWorkers) workerResultStreamArray := make([]<-chan WorkerResult, numWorkers) for workerIndex := 0; workerIndex < numWorkers; workerIndex++ { workerResultStreamArray[workerIndex] = func(id int, ticketStream chan *Ticket) chan WorkerResult { workerResultStreamArray[workerIndex] = func(id int, ticketStream <-chan *Ticket) <-chan WorkerResult { workerResultStream := make(chan WorkerResult) count := 0 Loading Loading @@ -123,7 +123,7 @@ func TestTicketsComplex(t *testing.T) { t.Logf("worker %d processed %d", i.ID, i.Count) processedTickets += i.Count } t.Logf("processed tickets: %d - process duration: %s", processedTickets, totalProcessDuration.String()) t.Logf("processed tickets: %d - total process duration: %s", processedTickets, totalProcessDuration.String()) if maxTickets != processedTickets { t.Errorf("the count of processed tickets is %d, expected %d", processedTickets, maxTickets) } Loading