From 88c786dab6f21c46c14eba2033d5174a1f0754db Mon Sep 17 00:00:00 2001 From: Sarah Meyer Date: Fri, 6 Oct 2017 12:58:55 -0700 Subject: [PATCH 1/3] tools, benchmark: test util benchmark --- benchmark/util/type-check.js | 4 ++-- test/parallel/test-benchmark-util.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-benchmark-util.js diff --git a/benchmark/util/type-check.js b/benchmark/util/type-check.js index 1d9a4f30ef0a9c..31628b5217810e 100644 --- a/benchmark/util/type-check.js +++ b/benchmark/util/type-check.js @@ -29,7 +29,7 @@ const bench = common.createBenchmark(main, { type: Object.keys(args), version: ['native', 'js'], argument: ['true', 'false-primitive', 'false-object'], - millions: ['5'] + n: [1e7] }, { flags: ['--expose-internals'] }); @@ -38,7 +38,7 @@ function main(conf) { const util = process.binding('util'); const types = require('internal/util/types'); - const n = (+conf.millions * 1e6) | 0; + const n = (+conf.n * 1e6) | 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..9124269f45433a --- /dev/null +++ b/test/parallel/test-benchmark-util.js @@ -0,0 +1,7 @@ +'use strict'; + +require('../common'); + +const runBenchmark = require('../common/benchmark'); + +runBenchmark('util', ['n=1', 'arguments=0']); From 7befb1c1b3272055bce78276a7cfc8af55069c37 Mon Sep 17 00:00:00 2001 From: Sarah Meyer Date: Wed, 11 Oct 2017 17:38:24 -0400 Subject: [PATCH 2/3] tools, benchmark: solidify benchmarking arguments --- benchmark/util/type-check.js | 4 ++-- test/parallel/test-benchmark-util.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmark/util/type-check.js b/benchmark/util/type-check.js index 31628b5217810e..3b7b090c2e3957 100644 --- a/benchmark/util/type-check.js +++ b/benchmark/util/type-check.js @@ -29,7 +29,7 @@ const bench = common.createBenchmark(main, { type: Object.keys(args), version: ['native', 'js'], argument: ['true', 'false-primitive', 'false-object'], - n: [1e7] + n: [5e6] }, { flags: ['--expose-internals'] }); @@ -38,7 +38,7 @@ function main(conf) { const util = process.binding('util'); const types = require('internal/util/types'); - const n = (+conf.n * 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 index 9124269f45433a..d01eafd7d3262a 100644 --- a/test/parallel/test-benchmark-util.js +++ b/test/parallel/test-benchmark-util.js @@ -4,4 +4,4 @@ require('../common'); const runBenchmark = require('../common/benchmark'); -runBenchmark('util', ['n=1', 'arguments=0']); +runBenchmark('util', ['n=1']); From 78ebc378a5fd12a004fa7ec86c21ad76c0e98216 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 27 Oct 2017 18:16:28 -0700 Subject: [PATCH 3/3] squash: arguments --- benchmark/util/format.js | 3 +++ benchmark/util/inspect-array.js | 3 +++ benchmark/util/type-check.js | 3 +++ test/parallel/test-benchmark-util.js | 9 ++++++++- 4 files changed, 17 insertions(+), 1 deletion(-) 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 3b7b090c2e3957..ee8dd7e4ece188 100644 --- a/benchmark/util/type-check.js +++ b/benchmark/util/type-check.js @@ -35,6 +35,9 @@ const bench = common.createBenchmark(main, { }); 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'); diff --git a/test/parallel/test-benchmark-util.js b/test/parallel/test-benchmark-util.js index d01eafd7d3262a..25140f8fe7ebc1 100644 --- a/test/parallel/test-benchmark-util.js +++ b/test/parallel/test-benchmark-util.js @@ -4,4 +4,11 @@ require('../common'); const runBenchmark = require('../common/benchmark'); -runBenchmark('util', ['n=1']); +runBenchmark('util', + ['argument=false', + 'input=', + 'method=Array', + 'n=1', + 'option=none', + 'type=', + 'version=native']);