benchmark: (util/v8/vm) use destructuring

PR-URL: https://github.com/nodejs/node/pull/18250
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Ruben Bridgewater 2017-12-30 03:55:33 +01:00
parent 5dfb93d2fa
commit 7a24b1c565
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
5 changed files with 12 additions and 21 deletions

View File

@ -47,11 +47,9 @@ function getInput(input) {
} }
} }
function main(conf) { function main({ input, n }) {
const normalizeEncoding = require('internal/util').normalizeEncoding; const { normalizeEncoding } = require('internal/util');
const inputs = getInput(input);
const n = conf.n | 0;
const inputs = getInput(conf.input);
var noDead = ''; var noDead = '';
bench.start(); bench.start();

View File

@ -34,16 +34,15 @@ const bench = common.createBenchmark(main, {
flags: ['--expose-internals'] flags: ['--expose-internals']
}); });
function main(conf) { function main({ type, argument, version, n }) {
// For testing, if supplied with an empty type, default to ArrayBufferView. // For testing, if supplied with an empty type, default to ArrayBufferView.
conf.type = conf.type || 'ArrayBufferView'; type = type || 'ArrayBufferView';
const util = process.binding('util'); const util = process.binding('util');
const types = require('internal/util/types'); const types = require('internal/util/types');
const n = (+conf.n) | 0; const func = { native: util, js: types }[version][`is${type}`];
const func = { native: util, js: types }[conf.version][`is${conf.type}`]; const arg = args[type][argument];
const arg = args[conf.type][conf.argument];
bench.start(); bench.start();
for (var i = 0; i < n; i++) { for (var i = 0; i < n; i++) {

View File

@ -11,9 +11,7 @@ const bench = common.createBenchmark(main, {
n: [1e6] n: [1e6]
}); });
function main(conf) { function main({ method, n }) {
const n = +conf.n;
const method = conf.method;
var i = 0; var i = 0;
bench.start(); bench.start();
for (; i < n; i++) for (; i < n; i++)

View File

@ -10,10 +10,8 @@ const bench = common.createBenchmark(main, {
const vm = require('vm'); const vm = require('vm');
function main(conf) { function main({ n, breakOnSigint, withSigintListener }) {
const n = +conf.n; const options = breakOnSigint ? { breakOnSigint: true } : {};
const options = conf.breakOnSigint ? { breakOnSigint: true } : {};
const withSigintListener = !!conf.withSigintListener;
process.removeAllListeners('SIGINT'); process.removeAllListeners('SIGINT');
if (withSigintListener) if (withSigintListener)

View File

@ -10,10 +10,8 @@ const bench = common.createBenchmark(main, {
const vm = require('vm'); const vm = require('vm');
function main(conf) { function main({ n, breakOnSigint, withSigintListener }) {
const n = +conf.n; const options = breakOnSigint ? { breakOnSigint: true } : {};
const options = conf.breakOnSigint ? { breakOnSigint: true } : {};
const withSigintListener = !!conf.withSigintListener;
process.removeAllListeners('SIGINT'); process.removeAllListeners('SIGINT');
if (withSigintListener) if (withSigintListener)