-
Notifications
You must be signed in to change notification settings - Fork 4.6k
benchmark: add benchmain/main.go to run benchmark with flag set #1352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Please resolve the conflicts and let us know when this is ready to review again. Sorry, thanks. |
bb5a09a
to
0619d4e
Compare
0619d4e
to
40dc89a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, minor suggestions
benchmark/benchmain/main.go
Outdated
}), | ||
) | ||
tc := testpb.NewBenchmarkServiceClient(conn) | ||
return func(pos int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is pos needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the runStream, it need the position to indicate which steam is using.
Since runUnary and runStream shares the same function runBenchmark, runUnary set a postion without using it.
benchmark/benchmain/main.go
Outdated
// Initiate main function to get settings of features. | ||
func init() { | ||
var runUnary, runStream bool | ||
var traceMode, noTraceMode bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have only one variable traceMode with default value to be false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I do the same with runCompressionMode
. false by default, true if set.
benchmark/benchmain/main.go
Outdated
*values = replace | ||
} | ||
|
||
func readTimeFromIntSlice(values *[]time.Duration, replace string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we change the name of this function since it isn't really reading from an intSlice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I don't know which name is better, so I change it from IntSlice to Input.
Ready for review.
benchmark/benchmain/main.go
Outdated
target, stopper := bm.StartServer(bm.ServerInfo{Addr: "localhost:0", Type: "protobuf", Network: nw}, sopts...) | ||
conn := bm.NewClientConn(target, opts...) | ||
tc := testpb.NewBenchmarkServiceClient(conn) | ||
return func(pos int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This could have have been an unnamed variable since this is not used in the function and is there only to maintain function signature.
return func(_ int) {
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If all your parameters are unnamed, you can do this instead:
return func(int) {
...
}
go run main.go -flag=xxx
.In benchmark17_test.go, it uses "b *testing.B" to calculate the allocations, and b.N to stop benchmarks. In main.go, it uses ReadMemStats and do the calculation by it's own and timeout to stop benchmarks.
An example of main.go is
go run benchmark/benchmain/main.go -kbps=0 -mtu=0 -maxConcurrentCalls=1 -reqSizeBytes=1,1048576 -reqspSizeBytes=1,1048576 -runUnary=true -runStream=true -traceMode=true -latency=0s,5ms -timeout=10s
Flags include
runUnary and runStream can be set both. traceMode and compressionMode are false by default.
All flags have default settings.
when cpuProfile or memProfile is set, it will save the profile result into the file.