mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 07:27:22 +01:00
fd45187d34
PR-URL: https://github.com/nodejs/node/pull/18250 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
37 lines
762 B
JavaScript
37 lines
762 B
JavaScript
'use strict';
|
|
const common = require('../common.js');
|
|
const spawn = require('child_process').spawn;
|
|
const path = require('path');
|
|
const emptyJsFile = path.resolve(__dirname, '../../test/fixtures/semicolon.js');
|
|
|
|
const bench = common.createBenchmark(startNode, {
|
|
dur: [1]
|
|
});
|
|
|
|
function startNode({ dur }) {
|
|
var go = true;
|
|
var starts = 0;
|
|
|
|
setTimeout(function() {
|
|
go = false;
|
|
}, dur * 1000);
|
|
|
|
bench.start();
|
|
start();
|
|
|
|
function start() {
|
|
const node = spawn(process.execPath || process.argv[0], [emptyJsFile]);
|
|
node.on('exit', function(exitCode) {
|
|
if (exitCode !== 0) {
|
|
throw new Error('Error during node startup');
|
|
}
|
|
starts++;
|
|
|
|
if (go)
|
|
start();
|
|
else
|
|
bench.end(starts);
|
|
});
|
|
}
|
|
}
|