mirror of https://github.com/lukechilds/node.git
Browse Source
Mostly shared/duplicated logic between all benchmark test files, so creating a new common module to store it. PR-URL: https://github.com/nodejs/node/pull/15004 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>canary-base
Jon Moss
7 years ago
committed by
Refael Ackermann
16 changed files with 140 additions and 276 deletions
@ -0,0 +1,30 @@ |
|||||
|
/* eslint-disable required-modules */ |
||||
|
|
||||
|
'use strict'; |
||||
|
|
||||
|
const assert = require('assert'); |
||||
|
const fork = require('child_process').fork; |
||||
|
const path = require('path'); |
||||
|
|
||||
|
const runjs = path.join(__dirname, '..', '..', 'benchmark', 'run.js'); |
||||
|
|
||||
|
function runBenchmark(name, args, env) { |
||||
|
const argv = []; |
||||
|
|
||||
|
for (let i = 0; i < args.length; i++) { |
||||
|
argv.push('--set'); |
||||
|
argv.push(args[i]); |
||||
|
} |
||||
|
|
||||
|
argv.push(name); |
||||
|
|
||||
|
const mergedEnv = Object.assign({}, process.env, env); |
||||
|
|
||||
|
const child = fork(runjs, argv, { env: mergedEnv }); |
||||
|
child.on('exit', (code, signal) => { |
||||
|
assert.strictEqual(code, 0); |
||||
|
assert.strictEqual(signal, null); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
module.exports = runBenchmark; |
Loading…
Reference in new issue