diff --git a/benchmark/util/format.js b/benchmark/util/format.js index 6f171318ee28bf..5f9c4c3b594497 100644 --- a/benchmark/util/format.js +++ b/benchmark/util/format.js @@ -21,6 +21,9 @@ const bench = common.createBenchmark(main, { }); function main({ n, type }) { + // For testing, if supplied with an empty type, default to string. + type = type || 'string'; + const [first, second] = inputs[type]; bench.start(); diff --git a/benchmark/util/inspect-array.js b/benchmark/util/inspect-array.js index 751e2c3c2deb8f..74332d18579865 100644 --- a/benchmark/util/inspect-array.js +++ b/benchmark/util/inspect-array.js @@ -18,6 +18,9 @@ function main({ n, len, type }) { var arr = Array(len); var i, opts; + // For testing, if supplied with an empty type, default to denseArray. + type = type || 'denseArray'; + switch (type) { case 'denseArray_showHidden': opts = { showHidden: true }; diff --git a/benchmark/util/type-check.js b/benchmark/util/type-check.js index c7e3de7de9fa09..b513c35a3caeb2 100644 --- a/benchmark/util/type-check.js +++ b/benchmark/util/type-check.js @@ -23,16 +23,19 @@ const bench = common.createBenchmark(main, { type: Object.keys(args), version: ['native', 'js'], argument: ['true', 'false-primitive', 'false-object'], - millions: ['5'] + n: [5e6] }, { flags: ['--expose-internals'] }); function main(conf) { + // For testing, if supplied with an empty type, default to ArrayBufferView. + conf.type = conf.type || 'ArrayBufferView'; + const util = process.binding('util'); const types = require('internal/util/types'); - const n = (+conf.millions * 1e6) | 0; + const n = (+conf.n) | 0; const func = { native: util, js: types }[conf.version][`is${conf.type}`]; const arg = args[conf.type][conf.argument]; diff --git a/test/parallel/test-benchmark-util.js b/test/parallel/test-benchmark-util.js new file mode 100644 index 00000000000000..25140f8fe7ebc1 --- /dev/null +++ b/test/parallel/test-benchmark-util.js @@ -0,0 +1,14 @@ +'use strict'; + +require('../common'); + +const runBenchmark = require('../common/benchmark'); + +runBenchmark('util', + ['argument=false', + 'input=', + 'method=Array', + 'n=1', + 'option=none', + 'type=', + 'version=native']);