mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
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:
parent
8e3d7623a5
commit
d49580d812
@ -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'] });
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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],
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user