Skip to content

Commit

Permalink
test: add test for child_process benchmark
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
joyeecheung authored and evanlucas committed Apr 25, 2017
1 parent 2957449 commit 80e8451
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
6 changes: 3 additions & 3 deletions benchmark/child_process/spawn-echo.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';
var common = require('../common.js');
var bench = common.createBenchmark(main, {
thousands: [1]
n: [1000]
});

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

bench.start();
go(len, len);
go(n, n);
}

function go(n, left) {
Expand Down
19 changes: 19 additions & 0 deletions test/sequential/test-benchmark-child-process.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

require('../common');

const assert = require('assert');
const fork = require('child_process').fork;
const path = require('path');

const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js');

const child = fork(runjs, ['--set', 'dur=0.1',
'--set', 'n=1',
'--set', 'len=1',
'child_process'],
{env: {NODEJS_BENCHMARK_ZERO_ALLOWED: 1}});
child.on('exit', (code, signal) => {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
});

0 comments on commit 80e8451

Please sign in to comment.