mirror of
https://github.com/nodejs/node.git
synced 2024-11-28 14:33:11 +01:00
8c9dc4e9e6
PR-URL: https://github.com/nodejs/node/pull/36972 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
33 lines
875 B
JavaScript
33 lines
875 B
JavaScript
// This benchmark is meant to exercise a grab bag of code paths that would
|
|
// be expected to run slower under coverage.
|
|
'use strict';
|
|
|
|
const common = require('../common.js');
|
|
const bench = common.createBenchmark(main, {
|
|
n: [1e5]
|
|
});
|
|
const path = require('path');
|
|
const { rmSync } = require('fs');
|
|
const { spawnSync } = require('child_process');
|
|
const tmpdir = require('../../test/common/tmpdir');
|
|
|
|
const coverageDir = path.join(tmpdir.path, `./cov-${Date.now()}`);
|
|
|
|
function main({ n }) {
|
|
bench.start();
|
|
const result = spawnSync(process.execPath, [
|
|
require.resolve('../fixtures/coverage-many-branches'),
|
|
], {
|
|
env: {
|
|
NODE_V8_COVERAGE: coverageDir,
|
|
N: n,
|
|
...process.env
|
|
}
|
|
});
|
|
bench.end(n);
|
|
rmSync(coverageDir, { recursive: true, force: true });
|
|
if (result.status !== 0) {
|
|
throw new Error(result.stderr.toString('utf8'));
|
|
}
|
|
}
|