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) {
const normalizeEncoding = require('internal/util').normalizeEncoding;
const n = conf.n | 0;
const inputs = getInput(conf.input);
function main({ input, n }) {
const { normalizeEncoding } = require('internal/util');
const inputs = getInput(input);
var noDead = '';
bench.start();

View File

@ -34,16 +34,15 @@ const bench = common.createBenchmark(main, {
flags: ['--expose-internals']
});
function main(conf) {
function main({ type, argument, version, n }) {
// 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 types = require('internal/util/types');
const n = (+conf.n) | 0;
const func = { native: util, js: types }[conf.version][`is${conf.type}`];
const arg = args[conf.type][conf.argument];
const func = { native: util, js: types }[version][`is${type}`];
const arg = args[type][argument];
bench.start();
for (var i = 0; i < n; i++) {

View File

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

View File

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

View File

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