Skip to content

Commit

Permalink
benchmark: cleanup child_process IPC benchmark
Browse files Browse the repository at this point in the history
Squashed from:
- child_process: fix IPC bench to obey send() ret val
- child_process: fix IPC benchmark message has two more bytes
- child_process: use setImmediate for IPC bench

PR-URL: #10557
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
ypresto authored and italoacasas committed Jan 27, 2017
1 parent fc2db50 commit 2f339e7
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions benchmark/child_process/child-process-read-ipc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
'use strict';
if (process.argv[2] === 'child') {
const len = +process.argv[3];
const msg = `"${'.'.repeat(len)}"`;
while (true) {
process.send(msg);
}
const msg = '.'.repeat(len);
const send = () => {
while (process.send(msg));
// Wait: backlog of unsent messages exceeds threshold
setImmediate(send);
};
send();
} else {
const common = require('../common.js');
const bench = common.createBenchmark(main, {
len: [64, 256, 1024, 4096, 32768],
len: [
64, 256, 1024, 4096, 16384, 65536,
65536 << 4, 65536 << 8
],
dur: [5]
});
const spawn = require('child_process').spawn;
Expand All @@ -18,7 +24,7 @@ if (process.argv[2] === 'child') {
const dur = +conf.dur;
const len = +conf.len;

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

Expand All @@ -29,8 +35,7 @@ if (process.argv[2] === 'child') {

setTimeout(function() {
child.kill();
const gbits = (bytes * 8) / (1024 * 1024 * 1024);
bench.end(gbits);
bench.end(bytes);
}, dur * 1000);
}
}

0 comments on commit 2f339e7

Please sign in to comment.