benchmark: (misc) 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>
pull/18259/merge
Ruben Bridgewater 2017-12-30 03:57:38 +01:00
parent 50d2554dd1
commit fd45187d34
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
6 changed files with 15 additions and 21 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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':

View File

@ -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':

View File

@ -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;

View File

@ -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; } });