Skip to content

Commit

Permalink
benchmark: (child_process) use destructuring
Browse files Browse the repository at this point in the history
PR-URL: #18250
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
BridgeAR authored and evanlucas committed Jan 30, 2018
1 parent 5cf5ab1 commit e19c77b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 20 deletions.
6 changes: 2 additions & 4 deletions benchmark/child_process/child-process-exec-stdout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'] });

Expand Down
6 changes: 1 addition & 5 deletions benchmark/child_process/child-process-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions benchmark/child_process/child-process-read-ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
5 changes: 1 addition & 4 deletions benchmark/child_process/child-process-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions benchmark/child_process/spawn-echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit e19c77b

Please sign in to comment.