()
| 48 | } |
| 49 | |
| 50 | func (wp workerPool) detectWords() int { |
| 51 | var numWordsDetected int |
| 52 | for word := range wp.msgs { |
| 53 | // simulate work |
| 54 | length := time.Duration(rand.Int63n(50)) |
| 55 | time.Sleep(length * time.Millisecond) |
| 56 | // this condition returns words like whale, whaling, whales |
| 57 | if strings.Contains(word, "whal") { |
| 58 | wp.mu.Lock() |
| 59 | numWordsDetected++ |
| 60 | wp.mu.Unlock() |
| 61 | } |
| 62 | } |
| 63 | return numWordsDetected |
| 64 | } |
| 65 | |
| 66 | // export cpu and mem profiles to a file that can be processed by pprof tool |
| 67 | func runPprof(memprofile, cpuprofile string) { |
nothing calls this directly
no outgoing calls
no test coverage detected