Skip to content

Commit

Permalink
benchmark: (misc) use destructuring
Browse files Browse the repository at this point in the history
PR-URL: #18250
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR authored and evanlucas committed Jan 30, 2018
1 parent d13d900 commit e9c426b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
3 changes: 1 addition & 2 deletions benchmark/misc/freelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ const bench = common.createBenchmark(main, {
flags: ['--expose-internals']
});

function main(conf) {
function main({ n }) {
const FreeList = require('internal/freelist');
const n = conf.n;
const poolSize = 1000;
const list = new FreeList('test', poolSize, Object);
var i;
Expand Down
8 changes: 4 additions & 4 deletions benchmark/misc/function_call/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ const bench = common.createBenchmark(main, {
millions: [1, 10, 50]
});

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

const fn = conf.type === 'cxx' ? cxx : js;
const fn = type === 'cxx' ? cxx : js;
bench.start();
for (var i = 0; i < n; i++) {
fn();
}
bench.end(+conf.millions);
bench.end(millions);
}
6 changes: 3 additions & 3 deletions benchmark/misc/object-property-bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ function runSymbol(n) {
bench.end(n / 1e6);
}

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

switch (conf.method) {
switch (method) {
// '' is a default case for tests
case '':
case 'property':
Expand Down
6 changes: 2 additions & 4 deletions benchmark/misc/punycode.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ function runICU(n, val) {
bench.end(n);
}

function main(conf) {
const n = +conf.n;
const val = conf.val;
switch (conf.method) {
function main({ n, val, method }) {
switch (method) {
// '' is a default case for tests
case '':
case 'punycode':
Expand Down
3 changes: 1 addition & 2 deletions benchmark/misc/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const bench = common.createBenchmark(startNode, {
dur: [1]
});

function startNode(conf) {
const dur = +conf.dur;
function startNode({ dur }) {
var go = true;
var starts = 0;

Expand Down
10 changes: 4 additions & 6 deletions benchmark/misc/util-extend-vs-object-assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ const bench = common.createBenchmark(main, {
n: [10e4]
});

function main(conf) {
function main({ n, type }) {
let fn;
const n = conf.n | 0;

if (conf.type === 'extend') {
if (type === 'extend') {
fn = util._extend;
} else if (conf.type === 'assign') {
} else if (type === 'assign') {
fn = Object.assign;
}

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

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

0 comments on commit e9c426b

Please sign in to comment.