fast ! ack go 6.24s user 1.06s system 99% cpu 7.304 total # ack ag go 0.88s user 1.39s system 221% cpu 1.027 total # ag pt go 1.09s user 1.01s system 235% cpu 0.892 total # pt
var wg sync.WaitGroup sem := make(chan bool, self.Option.Cap) // ىಈ͢ΔgoroutineͷΛ੍ޚ͢Δchannel for file := range self.Files { sem wg.Add(1) (தུ) go func(self *Grep, file *string) { defer wg.Done() for { ɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹɹ(தུ) } fh.Close() ! }(self, file) ! } wg.Wait() close(self.Matches)
–Rob Pike • Concurrency is powerful. • Concurrency is not parallelism. • Concurrency enables parallelism. • Concurrency makes parallelism (and scaling and everything else) easy.