2021-01-23 00:24:31 +01:00
|
|
|
// 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, {
|
2023-02-05 12:00:09 +01:00
|
|
|
n: [1e5],
|
2021-01-23 00:24:31 +01:00
|
|
|
});
|
|
|
|
const { rmSync } = require('fs');
|
|
|
|
const { spawnSync } = require('child_process');
|
|
|
|
const tmpdir = require('../../test/common/tmpdir');
|
|
|
|
|
2023-08-30 11:55:20 +02:00
|
|
|
const coverageDir = tmpdir.resolve(`cov-${Date.now()}`);
|
2021-01-23 00:24:31 +01:00
|
|
|
|
|
|
|
function main({ n }) {
|
|
|
|
bench.start();
|
|
|
|
const result = spawnSync(process.execPath, [
|
|
|
|
require.resolve('../fixtures/coverage-many-branches'),
|
|
|
|
], {
|
|
|
|
env: {
|
|
|
|
NODE_V8_COVERAGE: coverageDir,
|
|
|
|
N: n,
|
2023-02-05 12:00:09 +01:00
|
|
|
...process.env,
|
|
|
|
},
|
2021-01-23 00:24:31 +01:00
|
|
|
});
|
|
|
|
bench.end(n);
|
|
|
|
rmSync(coverageDir, { recursive: true, force: true });
|
|
|
|
if (result.status !== 0) {
|
|
|
|
throw new Error(result.stderr.toString('utf8'));
|
|
|
|
}
|
|
|
|
}
|