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

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

77
var spawn = require('child_process').spawn;
88
function main(conf) {
9-
var len = +conf.thousands * 1000;
9+
var n = +conf.n;
1010

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

1515
function go(n, left) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
require('../common');
4+
5+
const assert = require('assert');
6+
const fork = require('child_process').fork;
7+
const path = require('path');
8+
9+
const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js');
10+
11+
const child = 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)