Skip to content

Commit e19c77b

Browse files
BridgeARevanlucas
authored andcommitted
benchmark: (child_process) use destructuring
PR-URL: #18250 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 5cf5ab1 commit e19c77b

File tree

5 files changed

+7
-20
lines changed

5 files changed

+7
-20
lines changed

benchmark/child_process/child-process-exec-stdout.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ const bench = common.createBenchmark(childProcessExecStdout, {
1212
dur: [5]
1313
});
1414

15-
function childProcessExecStdout(conf) {
15+
function childProcessExecStdout({ dur, len }) {
1616
bench.start();
1717

18-
const maxDuration = conf.dur * 1000;
19-
const len = +conf.len;
20-
18+
const maxDuration = dur * 1000;
2119
const cmd = `yes "${'.'.repeat(len)}"`;
2220
const child = exec(cmd, { 'stdio': ['ignore', 'pipe', 'ignore'] });
2321

benchmark/child_process/child-process-params.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ const configs = {
2020

2121
const bench = common.createBenchmark(main, configs);
2222

23-
function main(conf) {
24-
const n = +conf.n;
25-
const methodName = conf.methodName;
26-
const params = +conf.params;
27-
23+
function main({ n, methodName, params }) {
2824
const method = cp[methodName];
2925

3026
switch (methodName) {

benchmark/child_process/child-process-read-ipc.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ if (process.argv[2] === 'child') {
1818
dur: [5]
1919
});
2020
const spawn = require('child_process').spawn;
21-
function main(conf) {
22-
bench.start();
2321

24-
const dur = +conf.dur;
25-
const len = +conf.len;
22+
function main({ dur, len }) {
23+
bench.start();
2624

2725
const options = { 'stdio': ['ignore', 1, 2, 'ipc'] };
2826
const child = spawn(process.argv[0],

benchmark/child_process/child-process-read.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ const bench = common.createBenchmark(main, {
1717
dur: [5]
1818
});
1919

20-
function main(conf) {
20+
function main({ dur, len }) {
2121
bench.start();
2222

23-
const dur = +conf.dur;
24-
const len = +conf.len;
25-
2623
const msg = `"${'.'.repeat(len)}"`;
2724
const options = { 'stdio': ['ignore', 'pipe', 'ignore'] };
2825
const child = child_process.spawn('yes', [msg], options);

benchmark/child_process/spawn-echo.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ const bench = common.createBenchmark(main, {
55
});
66

77
const spawn = require('child_process').spawn;
8-
function main(conf) {
9-
const n = +conf.n;
10-
8+
function main({ n }) {
119
bench.start();
1210
go(n, n);
1311
}

0 commit comments

Comments
 (0)