From 09a24e155e0a58994a8eb2032fa303fd101f353c Mon Sep 17 00:00:00 2001 From: Wang Guoliang Date: Tue, 3 Apr 2018 10:39:59 +0800 Subject: [PATCH] -Add cores of CPU feature --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index eea98ed..e0f76e6 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,7 @@ import ( "io/ioutil" "log" "os" + "runtime" "strings" "sync" "time" @@ -52,11 +53,14 @@ var ( exceptPackages = flag.String("e", "", "except packages.") templatePath = flag.String("t", "", "report html template path.") reportFormat = flag.String("f", "", "project report format(text/json/html).") + coresOfCPU = flag.Int("c", -1, "cores of CPU.") ) func main() { flag.Parse() - + if *coresOfCPU != -1 && *coresOfCPU <= runtime.NumCPU() { + runtime.GOMAXPROCS(*coresOfCPU) + } if *version { fmt.Printf("GoReporter %s\r\n", VERSION) os.Exit(0)