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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions benchmark/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function Benchmark(fn, configs, options) {
}

Benchmark.prototype._parseArgs = function(argv, configs) {
const cliOptions = Object.assign({}, configs);
const cliOptions = {};
const extraOptions = {};
// Parse configuration arguments
for (const arg of argv) {
Expand All @@ -47,17 +47,20 @@ Benchmark.prototype._parseArgs = function(argv, configs) {
console.error('bad argument: ' + arg);
process.exit(1);
}
const config = match[1];

if (configs[match[1]]) {
if (configs[config]) {
// Infer the type from the config object and parse accordingly
const isNumber = typeof configs[match[1]][0] === 'number';
const isNumber = typeof configs[config][0] === 'number';
const value = isNumber ? +match[2] : match[2];
cliOptions[match[1]] = [value];
if (!cliOptions[config])
cliOptions[config] = [];
cliOptions[config].push(value);
} else {
extraOptions[match[1]] = match[2];
extraOptions[config] = match[2];
}
}
return { cli: cliOptions, extra: extraOptions };
return { cli: Object.assign({}, configs, cliOptions), extra: extraOptions };
};

Benchmark.prototype._queue = function(options) {
Expand Down