benchmark: (child_process) 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>
This commit is contained in:
Ruben Bridgewater 2017-12-30 04:00:22 +01:00
parent 8e3d7623a5
commit d49580d812
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
5 changed files with 7 additions and 20 deletions

View File

@ -12,12 +12,10 @@ const bench = common.createBenchmark(childProcessExecStdout, {
dur: [5]
});
function childProcessExecStdout(conf) {
function childProcessExecStdout({ dur, len }) {
bench.start();
const maxDuration = conf.dur * 1000;
const len = +conf.len;
const maxDuration = dur * 1000;
const cmd = `yes "${'.'.repeat(len)}"`;
const child = exec(cmd, { 'stdio': ['ignore', 'pipe', 'ignore'] });

View File

@ -20,11 +20,7 @@ const configs = {
const bench = common.createBenchmark(main, configs);
function main(conf) {
const n = +conf.n;
const methodName = conf.methodName;
const params = +conf.params;
function main({ n, methodName, params }) {
const method = cp[methodName];
switch (methodName) {

View File

@ -18,11 +18,9 @@ if (process.argv[2] === 'child') {
dur: [5]
});
const spawn = require('child_process').spawn;
function main(conf) {
bench.start();
const dur = +conf.dur;
const len = +conf.len;
function main({ dur, len }) {
bench.start();
const options = { 'stdio': ['ignore', 1, 2, 'ipc'] };
const child = spawn(process.argv[0],

View File

@ -17,12 +17,9 @@ const bench = common.createBenchmark(main, {
dur: [5]
});
function main(conf) {
function main({ dur, len }) {
bench.start();
const dur = +conf.dur;
const len = +conf.len;
const msg = `"${'.'.repeat(len)}"`;
const options = { 'stdio': ['ignore', 'pipe', 'ignore'] };
const child = child_process.spawn('yes', [msg], options);

View File

@ -5,9 +5,7 @@ const bench = common.createBenchmark(main, {
});
const spawn = require('child_process').spawn;
function main(conf) {
const n = +conf.n;
function main({ n }) {
bench.start();
go(n, n);
}