Change cpu core set and var declaration

This commit is contained in:
Menghan Li 2016-04-28 16:43:23 -07:00
parent 3a13913bba
commit bb1be7190b
2 changed files with 12 additions and 9 deletions

View File

@ -91,15 +91,16 @@ func startBenchmarkClient(config *testpb.ClientConfig) (*benchmarkClient, error)
grpclog.Printf(" - core limit: %v", config.CoreLimit)
// Use one cpu core by default
numOfCores := 1
if config.CoreLimit > 0 {
numOfCores = int(config.CoreLimit)
// TODO: change default number of cores used if 1 is not fastest.
if config.CoreLimit > 1 {
runtime.GOMAXPROCS(int(config.CoreLimit))
}
runtime.GOMAXPROCS(numOfCores)
grpclog.Printf(" - payload config: %v", config.PayloadConfig)
var payloadReqSize, payloadRespSize int
var payloadType string
var (
payloadReqSize, payloadRespSize int
payloadType string
)
if config.PayloadConfig != nil {
switch c := config.PayloadConfig.Payload.(type) {
case *testpb.PayloadConfig_BytebufParams:

View File

@ -93,7 +93,7 @@ func startBenchmarkServer(config *testpb.ServerConfig, serverPort int) (*benchma
grpclog.Printf(" - core limit: %v", config.CoreLimit)
// Use one cpu core by default.
numOfCores := 1
if config.CoreLimit > 0 {
if config.CoreLimit > 1 {
numOfCores = int(config.CoreLimit)
}
runtime.GOMAXPROCS(numOfCores)
@ -108,8 +108,10 @@ func startBenchmarkServer(config *testpb.ServerConfig, serverPort int) (*benchma
}
grpclog.Printf(" - payload config: %v", config.PayloadConfig)
var addr string
var close func()
var (
addr string
close func()
)
if config.PayloadConfig != nil {
switch payload := config.PayloadConfig.Payload.(type) {
case *testpb.PayloadConfig_BytebufParams: