summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorNikolai Vavilov <vvnicholas@gmail.com>2017-03-12 23:31:37 +0200
committerNikolai Vavilov <vvnicholas@gmail.com>2017-03-22 19:41:24 +0200
commit43fa0a884765752e18bf70f4be13cc721ee866de (patch)
treefc9ede3964647124d29b43ea20733e82c998ab35 /benchmark
parente0a9ad1af244f8756a228a6d087b3a55ee4c0d14 (diff)
downloadandroid-node-v8-43fa0a884765752e18bf70f4be13cc721ee866de.tar.gz
android-node-v8-43fa0a884765752e18bf70f4be13cc721ee866de.tar.bz2
android-node-v8-43fa0a884765752e18bf70f4be13cc721ee866de.zip
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: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/common.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/benchmark/common.js b/benchmark/common.js
index 7ce180fdb7..24369f2f54 100644
--- a/benchmark/common.js
+++ b/benchmark/common.js
@@ -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) {
@@ -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) {