Skip to content
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

benchmark: allow multiple values for same config #11819

Merged
merged 1 commit into from
Mar 22, 2017
Merged

benchmark: allow multiple values for same config #11819

merged 1 commit into from
Mar 22, 2017

Conversation

seishun
Copy link
Contributor

@seishun seishun commented Mar 12, 2017

This allows running a benchmark with two or more values for the same option rather than just one or all of them, for example:

node benchmark/buffers/buffer-creation.js type=buffer() type=fast-alloc type=fast-alloc-fill
Checklist
  • commit message follows commit guidelines
Affected core subsystem(s)

benchmark

@nodejs-github-bot nodejs-github-bot added the benchmark Issues and PRs related to the benchmark subsystem. label Mar 12, 2017
@seishun
Copy link
Contributor Author

seishun commented Mar 12, 2017

Per 2826e63, maybe the correct term would be "config" rather than "option".

@joyeecheung
Copy link
Member

Yes, those are configs because they are not optional. The third argument to createBenchmark is.

@seishun seishun changed the title benchmark: allow multiple values for same option benchmark: allow multiple values for same config Mar 13, 2017
@seishun
Copy link
Contributor Author

seishun commented Mar 13, 2017

Updated commit message.

@jasnell
Copy link
Member

jasnell commented Mar 15, 2017

@mscdex @nodejs/benchmarking

@@ -52,12 +52,13 @@ Benchmark.prototype._parseArgs = function(argv, configs) {
// Infer the type from the config object and parse accordingly
const isNumber = typeof configs[match[1]][0] === 'number';
const value = isNumber ? +match[2] : match[2];
cliOptions[match[1]] = [value];
if (!cliOptions[match[1]]) cliOptions[match[1]] = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assign match[1] to a variable and make the block of this conditional indented on the following line instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assign match[1] to a variable

Sure, if you suggest a variable name.

make the block of this conditional indented on the following line instead?

I'd then have to wrap it in braces, causing this simple default-assignment to take up three lines. But if that's how it's usually done in node's code, then so be it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't need braces.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as a variable name goes, I don't really have a preference. How about something simple like param?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't need braces.

Really? I think I've always seen single-line conditional bodies wrapped in braces in node's codebase, so I assumed that's our style.

As far as a variable name goes, I don't really have a preference.

If you don't have a preference, I'll go with config instead.

Copy link
Contributor

@mscdex mscdex Mar 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? I think I've always seen single-line conditional bodies wrapped in braces in node's codebase, so I assumed that's our style.

It's a mix. There is no strict rule for it, although the one time you definitely would want to use braces for a single line is if the conditional part spans multiple lines.

Personally when I am visually scanning code and I see an if or similar control flow statement, I assume the next line is part of its body. So cases like this just it harder to read (at least for me). Also it's visually easier/quicker to see where the conditional part ends. About the only time I ever create such lines of code is when I'm really short on space when I'm trying to make a function inlineable with Crankshaft, and even then I try to leave at least an empty line afterwards.

@seishun
Copy link
Contributor Author

seishun commented Mar 15, 2017

@mscdex in case Github didn't send a notification: PTAL.

@mscdex
Copy link
Contributor

mscdex commented Mar 15, 2017

LGTM

@fhinkel
Copy link
Member

fhinkel commented Mar 15, 2017

Thanks, squashed and landed in 5d9b1e8a635473b4caafe09ad9c971e2aa297d93

@fhinkel fhinkel closed this Mar 15, 2017
@seishun
Copy link
Contributor Author

seishun commented Mar 15, 2017

@fhinkel it seems you changed the example command line in the commit message to span two lines. I think it should be on a single line for clarity and readability. Could you force-push?

@seishun
Copy link
Contributor Author

seishun commented Mar 15, 2017

I went ahead and force-pushed. I'm okay with wrapping a command line if there is agreement that it should be, but I'd prefer to confirm it first.

@seishun seishun reopened this Mar 15, 2017
@jasnell
Copy link
Member

jasnell commented Mar 22, 2017

@seishun ... did you intend to reopen this? Is this landed?

@seishun
Copy link
Contributor Author

seishun commented Mar 22, 2017

@jasnell It's not landed currently. I wanted to postpone landing until I get some input on whether the example command line in the commit message should be wrapped. (I think it shouldn't because it's not prose and wrapping would make it less clear)

@jasnell
Copy link
Member

jasnell commented Mar 22, 2017

wrapping shouldn't be necessary, but I would prefer it to be included in a code block .. e.g. using ```

This allows running a benchmark with two or more values for the same
config rather than just one or all of them, for example:

```
node benchmark/buffers/buffer-creation.js type=buffer() type=fast-alloc type=fast-alloc-fill
```

PR-URL: #11819
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
@seishun
Copy link
Contributor Author

seishun commented Mar 22, 2017

Agreed. I've added a code block.

@seishun
Copy link
Contributor Author

seishun commented Mar 22, 2017

Landed in 43fa0a8.

@seishun seishun closed this Mar 22, 2017
@seishun seishun merged commit 43fa0a8 into nodejs:master Mar 22, 2017
MylesBorins pushed a commit that referenced this pull request Mar 28, 2017
This allows running a benchmark with two or more values for the same
config rather than just one or all of them, for example:

```
node benchmark/buffers/buffer-creation.js type=buffer() type=fast-alloc type=fast-alloc-fill
```

PR-URL: #11819
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
@MylesBorins MylesBorins mentioned this pull request Mar 28, 2017
@italoacasas italoacasas mentioned this pull request Apr 10, 2017
2 tasks
@MylesBorins
Copy link
Contributor

should thi sbackport? I'm not familiar with the benchmark setup so not in a good place to test this

@seishun
Copy link
Contributor Author

seishun commented Apr 18, 2017

No, I don't think it's worth bothering.

@seishun seishun deleted the multi-options branch October 19, 2017 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
benchmark Issues and PRs related to the benchmark subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants