-
Notifications
You must be signed in to change notification settings - Fork 8
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
The number of logical CPUs can be now set using --cpus flag #31
Conversation
306d035
to
50e6506
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.
Thank you for taking the time to implement this feature!
I only have some minor comments on code formatting, flag description and config default value. Also, would you mind adding an appropriate change to README.md? For now, adding --cpus
flag to help output will be sufficient, as the there is a documentation overhaul planned in #26 anyway.
integration_test.go
Outdated
@@ -112,6 +114,7 @@ func TestGocannonDefaultValues(t *testing.T) { | |||
cfg := common.Config{ | |||
Duration: &duration, | |||
Connections: &connections, | |||
CPUs: &cpus, |
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.
There is a minor formatting issue here - tabs between :
and &
instead of spaces
integration_test.go
Outdated
@@ -161,6 +165,7 @@ func TestGocanonWithPlugin(t *testing.T) { | |||
cfg := common.Config{ | |||
Duration: &duration, | |||
Connections: &connections, | |||
CPUs: &cpus, |
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.
Same here - tabs instead of spaces
args.go
Outdated
@@ -44,6 +46,9 @@ func parseArgs() (common.Config, error) { | |||
PlaceHolder("file.csv"). | |||
Short('o'). | |||
String(), | |||
CPUs: app.Flag("cpus", "Maximum number of logical CPUs"). |
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.
Descriptions of all other flags end with a full stop. One extra sentence could be added: Defaults to the number of available CPU threads (or the GOMAXPROCS env variable).
args.go
Outdated
@@ -44,6 +46,9 @@ func parseArgs() (common.Config, error) { | |||
PlaceHolder("file.csv"). | |||
Short('o'). | |||
String(), | |||
CPUs: app.Flag("cpus", "Maximum number of logical CPUs"). | |||
Default(strconv.Itoa(runtime.NumCPU())). |
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.
I'm a bit ify about setting the default value to runtime.NumCPU
as it is possible that someone running Gocannon might set the desired value via GOMAXPROCS
env variable. Consequently, such setting would be overwritten. Instead, I would suggest not setting the Default value at all, so that it is initialized with 0, which will not alter the existing value when passed to runtime.GOMAXPROCS()
. Ditching the default flag value would require modifying printHeader()
so that it retrieves the value from GOMAXPROCS()
if the config value equals 0.
This pull request adds the feature mentioned in issue #20