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‎

Lines changed: 9 additions & 6 deletions
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-
constcliOptions=Object.assign({},configs);
41+
constcliOptions={};
4242
constextraOptions={};
4343
// Parse configuration arguments
4444
for(constargofargv){
@@ -47,17 +47,20 @@ Benchmark.prototype._parseArgs = function(argv, configs){
4747
console.error('bad argument: '+arg);
4848
process.exit(1);
4949
}
50+
constconfig=match[1];
5051

51-
if(configs[match[1]]){
52+
if(configs[config]){
5253
// Infer the type from the config object and parse accordingly
53-
constisNumber=typeofconfigs[match[1]][0]==='number';
54+
constisNumber=typeofconfigs[config][0]==='number';
5455
constvalue=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)