Skip to content

Commit e9c426b

Browse files
BridgeARevanlucas
authored andcommitted
benchmark: (misc) use destructuring
PR-URL: #18250 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d13d900 commit e9c426b

File tree

6 files changed

+15
-21
lines changed

6 files changed

+15
-21
lines changed

benchmark/misc/freelist.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ const bench = common.createBenchmark(main, {
88
flags: ['--expose-internals']
99
});
1010

11-
function main(conf) {
11+
function main({ n }) {
1212
const FreeList = require('internal/freelist');
13-
const n = conf.n;
1413
const poolSize = 1000;
1514
const list = new FreeList('test', poolSize, Object);
1615
var i;

benchmark/misc/function_call/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ const bench = common.createBenchmark(main, {
3131
millions: [1, 10, 50]
3232
});
3333

34-
function main(conf) {
35-
const n = +conf.millions * 1e6;
34+
function main({ millions, type }) {
35+
const n = millions * 1e6;
3636

37-
const fn = conf.type === 'cxx' ? cxx : js;
37+
const fn = type === 'cxx' ? cxx : js;
3838
bench.start();
3939
for (var i = 0; i < n; i++) {
4040
fn();
4141
}
42-
bench.end(+conf.millions);
42+
bench.end(millions);
4343
}

benchmark/misc/object-property-bench.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ function runSymbol(n) {
5959
bench.end(n / 1e6);
6060
}
6161

62-
function main(conf) {
63-
const n = +conf.millions * 1e6;
62+
function main({ millions, method }) {
63+
const n = millions * 1e6;
6464

65-
switch (conf.method) {
65+
switch (method) {
6666
// '' is a default case for tests
6767
case '':
6868
case 'property':

benchmark/misc/punycode.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ function runICU(n, val) {
6262
bench.end(n);
6363
}
6464

65-
function main(conf) {
66-
const n = +conf.n;
67-
const val = conf.val;
68-
switch (conf.method) {
65+
function main({ n, val, method }) {
66+
switch (method) {
6967
// '' is a default case for tests
7068
case '':
7169
case 'punycode':

benchmark/misc/startup.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ const bench = common.createBenchmark(startNode, {
88
dur: [1]
99
});
1010

11-
function startNode(conf) {
12-
const dur = +conf.dur;
11+
function startNode({ dur }) {
1312
var go = true;
1413
var starts = 0;
1514

benchmark/misc/util-extend-vs-object-assign.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@ const bench = common.createBenchmark(main, {
88
n: [10e4]
99
});
1010

11-
function main(conf) {
11+
function main({ n, type }) {
1212
let fn;
13-
const n = conf.n | 0;
14-
15-
if (conf.type === 'extend') {
13+
if (type === 'extend') {
1614
fn = util._extend;
17-
} else if (conf.type === 'assign') {
15+
} else if (type === 'assign') {
1816
fn = Object.assign;
1917
}
2018

2119
// Force-optimize the method to test so that the benchmark doesn't
2220
// get disrupted by the optimizer kicking in halfway through.
23-
for (var i = 0; i < conf.type.length * 10; i += 1)
21+
for (var i = 0; i < type.length * 10; i += 1)
2422
fn({}, process.env);
2523

2624
const obj = new Proxy({}, { set: function(a, b, c) { return true; } });

0 commit comments

Comments
 (0)