added ngo flag and default worker value (NumCpu) #4

Merged
sm merged 1 commits from dm/cs:num-goroutine into master 2016-11-16 00:25:05 -08:00
2 changed files with 3 additions and 2 deletions

View File

@ -94,8 +94,7 @@ func check(files []string) chan error {
results := []<-chan error{} results := []<-chan error{}
workers := 32 for w := 0; w < *ngo; w++ {
for w := 0; w < workers; w++ {
results = append(results, compute(jobs)) results = append(results, compute(jobs))
} }

View File

@ -9,10 +9,12 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"runtime"
) )
var algo = flag.String("a", "sha1", "algorithm to use") var algo = flag.String("a", "sha1", "algorithm to use")
var mode = flag.Bool("c", false, "check") var mode = flag.Bool("c", false, "check")
var ngo = flag.Int("n", runtime.NumCPU(), "number of goroutines")
func main() { func main() {
flag.Parse() flag.Parse()