From e919941a2181129dee07fb782b928c8a14ed804c Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Tue, 11 Apr 2017 11:18:48 +0800 Subject: [PATCH] test: add test for child_process benchmark PR-URL: https://github.com/nodejs/node/pull/12326 Ref: https://github.com/nodejs/node/issues/12068 Reviewed-By: Vse Mozhet Byt Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Alexey Orlenko --- benchmark/child_process/spawn-echo.js | 6 +++--- .../test-benchmark-child-process.js | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 test/sequential/test-benchmark-child-process.js diff --git a/benchmark/child_process/spawn-echo.js b/benchmark/child_process/spawn-echo.js index 7c9e851aac..72822f87db 100644 --- a/benchmark/child_process/spawn-echo.js +++ b/benchmark/child_process/spawn-echo.js @@ -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) { diff --git a/test/sequential/test-benchmark-child-process.js b/test/sequential/test-benchmark-child-process.js new file mode 100644 index 0000000000..4acad7d0f7 --- /dev/null +++ b/test/sequential/test-benchmark-child-process.js @@ -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); +});