Skip to content

Commit ee3e324

Browse files
authored
add flag for setting runtime.GOMAXPROCS (#35)
* add flag for setting runtime.GOMAXPROCS
1 parent d65f05c commit ee3e324

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

cmd/go-tpc/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"os"
88
"os/signal"
9-
"runtime"
109
"strings"
1110
"syscall"
1211
"time"
@@ -34,6 +33,7 @@ var (
3433
silence bool
3534
summaryReport bool
3635
pprofAddr string
36+
maxProcs int
3737

3838
globalDB *sql.DB
3939
globalCtx context.Context
@@ -83,8 +83,7 @@ func main() {
8383
Use: "go-tpc",
8484
Short: "Benchmark database with different workloads",
8585
}
86-
runtime.GOMAXPROCS(runtime.NumCPU())
87-
86+
rootCmd.PersistentFlags().IntVar(&maxProcs, "max-procs", 0, "runtime.GOMAXPROCS")
8887
rootCmd.PersistentFlags().StringVar(&pprofAddr, "pprof", "", "Address of pprof endpoint")
8988
rootCmd.PersistentFlags().StringVarP(&dbName, "db", "D", "test", "Database name")
9089
rootCmd.PersistentFlags().StringVarP(&host, "host", "H", "127.0.0.1", "Database host")

cmd/go-tpc/tpcc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http"
77
_ "net/http/pprof"
88
"os"
9+
"runtime"
910

1011
"github.com/pingcap/go-tpc/tpcc"
1112
"github.com/spf13/cobra"
@@ -19,6 +20,7 @@ func executeTpcc(action string) {
1920
http.ListenAndServe(pprofAddr, http.DefaultServeMux)
2021
}()
2122
}
23+
runtime.GOMAXPROCS(maxProcs)
2224

2325
openDB()
2426
defer closeDB()

0 commit comments

Comments
 (0)