Skip to content

Commit e919941

Browse files
joyeecheungevanlucas
authored andcommitted
test: add test for child_process benchmark
PR-URL: #12326 Ref: #12068 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]>
1 parent 9db4f19 commit e919941

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

‎benchmark/child_process/spawn-echo.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
'use strict';
22
varcommon=require('../common.js');
33
varbench=common.createBenchmark(main,{
4-
thousands: [1]
4+
n: [1000]
55
});
66

77
varspawn=require('child_process').spawn;
88
functionmain(conf){
9-
varlen=+conf.thousands*1000;
9+
varn=+conf.n;
1010

1111
bench.start();
12-
go(len,len);
12+
go(n,n);
1313
}
1414

1515
functiongo(n,left){
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
require('../common');
4+
5+
constassert=require('assert');
6+
constfork=require('child_process').fork;
7+
constpath=require('path');
8+
9+
construnjs=path.join(__dirname,'..','..','benchmark','run.js');
10+
11+
constchild=fork(runjs,['--set','dur=0.1',
12+
'--set','n=1',
13+
'--set','len=1',
14+
'child_process'],
15+
{env: {NODEJS_BENCHMARK_ZERO_ALLOWED: 1}});
16+
child.on('exit',(code,signal)=>{
17+
assert.strictEqual(code,0);
18+
assert.strictEqual(signal,null);
19+
});

0 commit comments

Comments
(0)