added ngo flag and default worker value (NumCpu)

This commit is contained in:
Derek McQuay 2016-11-15 21:28:01 -08:00
parent 8d0ecfdc7f
commit b11c4701c3
No known key found for this signature in database
GPG Key ID: 92A7BC0C86B0B91A
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()