Skip to content

Commit c0707c5

Browse files
BridgeARevanlucas
authored andcommitted
benchmark: (util/v8/vm) use destructuring
PR-URL: #18250 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 76f671b commit c0707c5

File tree

5 files changed

+12
-21
lines changed

5 files changed

+12
-21
lines changed

benchmark/util/normalize-encoding.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ function getInput(input) {
4747
}
4848
}
4949

50-
function main(conf) {
51-
const normalizeEncoding = require('internal/util').normalizeEncoding;
52-
53-
const n = conf.n | 0;
54-
const inputs = getInput(conf.input);
50+
function main({ input, n }) {
51+
const { normalizeEncoding } = require('internal/util');
52+
const inputs = getInput(input);
5553
var noDead = '';
5654

5755
bench.start();

benchmark/util/type-check.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,15 @@ const bench = common.createBenchmark(main, {
3434
flags: ['--expose-internals']
3535
});
3636

37-
function main(conf) {
37+
function main({ type, argument, version, n }) {
3838
// For testing, if supplied with an empty type, default to ArrayBufferView.
39-
conf.type = conf.type || 'ArrayBufferView';
39+
type = type || 'ArrayBufferView';
4040

4141
const util = process.binding('util');
4242
const types = require('internal/util/types');
4343

44-
const n = (+conf.n) | 0;
45-
const func = { native: util, js: types }[conf.version][`is${conf.type}`];
46-
const arg = args[conf.type][conf.argument];
44+
const func = { native: util, js: types }[version][`is${type}`];
45+
const arg = args[type][argument];
4746

4847
bench.start();
4948
for (var i = 0; i < n; i++) {

benchmark/v8/get-stats.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ const bench = common.createBenchmark(main, {
1111
n: [1e6]
1212
});
1313

14-
function main(conf) {
15-
const n = +conf.n;
16-
const method = conf.method;
14+
function main({ method, n }) {
1715
var i = 0;
1816
bench.start();
1917
for (; i < n; i++)

benchmark/vm/run-in-context.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ const bench = common.createBenchmark(main, {
1010

1111
const vm = require('vm');
1212

13-
function main(conf) {
14-
const n = +conf.n;
15-
const options = conf.breakOnSigint ? { breakOnSigint: true } : {};
16-
const withSigintListener = !!conf.withSigintListener;
13+
function main({ n, breakOnSigint, withSigintListener }) {
14+
const options = breakOnSigint ? { breakOnSigint: true } : {};
1715

1816
process.removeAllListeners('SIGINT');
1917
if (withSigintListener)

benchmark/vm/run-in-this-context.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ const bench = common.createBenchmark(main, {
1010

1111
const vm = require('vm');
1212

13-
function main(conf) {
14-
const n = +conf.n;
15-
const options = conf.breakOnSigint ? { breakOnSigint: true } : {};
16-
const withSigintListener = !!conf.withSigintListener;
13+
function main({ n, breakOnSigint, withSigintListener }) {
14+
const options = breakOnSigint ? { breakOnSigint: true } : {};
1715

1816
process.removeAllListeners('SIGINT');
1917
if (withSigintListener)

0 commit comments

Comments
 (0)