Skip to content

Commit 90acb77

Browse files
seishunMylesBorins
authored andcommitted
benchmark: allow multiple values for same config
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 6a6c431 commit 90acb77

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

benchmark/common.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function Benchmark(fn, configs, options) {
3838
}
3939

4040
Benchmark.prototype._parseArgs = function(argv, configs) {
41-
const cliOptions = Object.assign({}, configs);
41+
const cliOptions = {};
4242
const extraOptions = {};
4343
// Parse configuration arguments
4444
for (const arg of argv) {
@@ -47,17 +47,20 @@ Benchmark.prototype._parseArgs = function(argv, configs) {
4747
console.error('bad argument: ' + arg);
4848
process.exit(1);
4949
}
50+
const config = match[1];
5051

51-
if (configs[match[1]]) {
52+
if (configs[config]) {
5253
// Infer the type from the config object and parse accordingly
53-
const isNumber = typeof configs[match[1]][0] === 'number';
54+
const isNumber = typeof configs[config][0] === 'number';
5455
const value = isNumber ? +match[2] : match[2];
55-
cliOptions[match[1]] = [value];
56+
if (!cliOptions[config])
57+
cliOptions[config] = [];
58+
cliOptions[config].push(value);
5659
} else {
57-
extraOptions[match[1]] = match[2];
60+
extraOptions[config] = match[2];
5861
}
5962
}
60-
return { cli: cliOptions, extra: extraOptions };
63+
return { cli: Object.assign({}, configs, cliOptions), extra: extraOptions };
6164
};
6265

6366
Benchmark.prototype._queue = function(options) {

0 commit comments

Comments
 (0)