Skip to content

Commit

Permalink
benchmark: (util/v8/vm) use destructuring
Browse files Browse the repository at this point in the history
PR-URL: #18250
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
BridgeAR authored and evanlucas committed Jan 30, 2018
1 parent 76f671b commit c0707c5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 21 deletions.
8 changes: 3 additions & 5 deletions benchmark/util/normalize-encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 4 additions & 5 deletions benchmark/util/type-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
4 changes: 1 addition & 3 deletions benchmark/v8/get-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
6 changes: 2 additions & 4 deletions benchmark/vm/run-in-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions benchmark/vm/run-in-this-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c0707c5

Please sign in to comment.