()
| 110 | } |
| 111 | |
| 112 | func main() { |
| 113 | numWorkers := flag.Int("workers", 1, "number of workers") |
| 114 | cpuprofile := flag.String("cpuprofile", "", "write cpu profile to `file`") |
| 115 | memprofile := flag.String("memprofile", "", "write memory profile to `file`") |
| 116 | |
| 117 | flag.Parse() |
| 118 | startTime := time.Now() |
| 119 | |
| 120 | // run pprof |
| 121 | runPprof(*cpuprofile, *memprofile) |
| 122 | |
| 123 | workerPool := &workerPool{ |
| 124 | wg: new(sync.WaitGroup), |
| 125 | msgs: make(chan string), |
| 126 | numWorkers: *numWorkers, |
| 127 | mu: new(sync.Mutex), |
| 128 | } |
| 129 | |
| 130 | // start the workers in the background and wait for data on the channel |
| 131 | // we already know the number of workers, we can increase the WaitGroup once |
| 132 | go workerPool.queueMessages() |
| 133 | numWords := workerPool.run() |
| 134 | fmt.Printf("Number of words: %d\nTime to process file: %2f seconds", numWords, time.Since(startTime).Seconds()) |
| 135 | } |
nothing calls this directly
no test coverage detected