Skip to content

Commit 32fa37f

Browse files
yprestoaddaleax
authored andcommitted
benchmark: cleanup child_process IPC benchmark
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]>
1 parent cd1a7ea commit 32fa37f

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
'use strict';
22
if(process.argv[2]==='child'){
33
constlen=+process.argv[3];
4-
constmsg=`"${'.'.repeat(len)}"`;
5-
while(true){
6-
process.send(msg);
7-
}
4+
constmsg='.'.repeat(len);
5+
constsend=()=>{
6+
while(process.send(msg));
7+
// Wait: backlog of unsent messages exceeds threshold
8+
setImmediate(send);
9+
};
10+
send();
811
}else{
912
constcommon=require('../common.js');
1013
constbench=common.createBenchmark(main,{
11-
len: [64,256,1024,4096,32768],
14+
len: [
15+
64,256,1024,4096,16384,65536,
16+
65536<<4,65536<<8
17+
],
1218
dur: [5]
1319
});
1420
constspawn=require('child_process').spawn;
@@ -18,7 +24,7 @@ if (process.argv[2] === 'child'){
1824
constdur=+conf.dur;
1925
constlen=+conf.len;
2026

21-
constoptions={'stdio': ['ignore','ignore','ignore','ipc']};
27+
constoptions={'stdio': ['ignore',1,2,'ipc']};
2228
constchild=spawn(process.argv[0],
2329
[process.argv[1],'child',len],options);
2430

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

3036
setTimeout(function(){
3137
child.kill();
32-
constgbits=(bytes*8)/(1024*1024*1024);
33-
bench.end(gbits);
38+
bench.end(bytes);
3439
},dur*1000);
3540
}
3641
}

0 commit comments

Comments
(0)