benchmark: use destructuring
This applies to all `async_hooks`, `dns`, `cluster`, `domain` and `module` benchmarks. 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>
This commit is contained in:
parent
b2966043c9
commit
6394c8d99d
@ -21,10 +21,8 @@ function endAfterGC(n) {
|
||||
});
|
||||
}
|
||||
|
||||
function main(conf) {
|
||||
const n = +conf.n;
|
||||
|
||||
switch (conf.method) {
|
||||
function main({ n, method }) {
|
||||
switch (method) {
|
||||
case 'trackingEnabled':
|
||||
bench.start();
|
||||
for (let i = 0; i < n; i++) {
|
||||
|
@ -10,22 +10,19 @@ if (cluster.isMaster) {
|
||||
n: [1e5]
|
||||
});
|
||||
|
||||
function main(conf) {
|
||||
const n = +conf.n;
|
||||
const workers = +conf.workers;
|
||||
const sends = +conf.sendsPerBroadcast;
|
||||
const expectedPerBroadcast = sends * workers;
|
||||
var payload;
|
||||
function main({ n, workers, sendsPerBroadcast, payload }) {
|
||||
const expectedPerBroadcast = sendsPerBroadcast * workers;
|
||||
var readies = 0;
|
||||
var broadcasts = 0;
|
||||
var msgCount = 0;
|
||||
var data;
|
||||
|
||||
switch (conf.payload) {
|
||||
switch (payload) {
|
||||
case 'string':
|
||||
payload = 'hello world!';
|
||||
data = 'hello world!';
|
||||
break;
|
||||
case 'object':
|
||||
payload = { action: 'pewpewpew', powerLevel: 9001 };
|
||||
data = { action: 'pewpewpew', powerLevel: 9001 };
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unsupported payload type');
|
||||
@ -51,8 +48,8 @@ if (cluster.isMaster) {
|
||||
}
|
||||
for (id in cluster.workers) {
|
||||
const worker = cluster.workers[id];
|
||||
for (var i = 0; i < sends; ++i)
|
||||
worker.send(payload);
|
||||
for (var i = 0; i < sendsPerBroadcast; ++i)
|
||||
worker.send(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,13 +9,10 @@ const bench = common.createBenchmark(main, {
|
||||
n: [5e6]
|
||||
});
|
||||
|
||||
function main(conf) {
|
||||
const name = conf.name;
|
||||
const n = +conf.n;
|
||||
const all = conf.all === 'true' ? true : false;
|
||||
function main({ name, n, all }) {
|
||||
var i = 0;
|
||||
|
||||
if (all) {
|
||||
if (all === 'true') {
|
||||
const opts = { all: true };
|
||||
bench.start();
|
||||
(function cb() {
|
||||
|
@ -3,17 +3,15 @@ const common = require('../common.js');
|
||||
const domain = require('domain');
|
||||
|
||||
const bench = common.createBenchmark(main, {
|
||||
arguments: [0, 1, 2, 3],
|
||||
args: [0, 1, 2, 3],
|
||||
n: [10]
|
||||
});
|
||||
|
||||
const bdomain = domain.create();
|
||||
const gargs = [1, 2, 3];
|
||||
|
||||
function main(conf) {
|
||||
|
||||
const n = +conf.n;
|
||||
const myArguments = gargs.slice(0, conf.arguments);
|
||||
function main({ n, args }) {
|
||||
const myArguments = gargs.slice(0, args);
|
||||
bench.start();
|
||||
|
||||
bdomain.enter();
|
||||
|
@ -12,8 +12,8 @@ const bench = common.createBenchmark(main, {
|
||||
useCache: ['true', 'false']
|
||||
});
|
||||
|
||||
function main(conf) {
|
||||
const n = +conf.thousands * 1e3;
|
||||
function main({ thousands, fullPath, useCache }) {
|
||||
const n = thousands * 1e3;
|
||||
|
||||
refreshTmpDir();
|
||||
try { fs.mkdirSync(benchmarkDirectory); } catch (e) {}
|
||||
@ -30,10 +30,10 @@ function main(conf) {
|
||||
);
|
||||
}
|
||||
|
||||
if (conf.fullPath === 'true')
|
||||
measureFull(n, conf.useCache === 'true');
|
||||
if (fullPath === 'true')
|
||||
measureFull(n, useCache === 'true');
|
||||
else
|
||||
measureDir(n, conf.useCache === 'true');
|
||||
measureDir(n, useCache === 'true');
|
||||
|
||||
refreshTmpDir();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user