Files
node/test/parallel/test-bench-auto-run.js
RafaelGSS 299f76cb73 lib: default node:bench warmup to 10 invocations
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs/node/pull/66536
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
2026-10-07 15:38:44 -03:00

30 lines
887 B
JavaScript

// Flags: --experimental-bench --no-warnings
'use strict';
const common = require('../common');
const assert = require('assert');
const { spawnSync } = require('child_process');
const { bench } = require('node:bench');
const child = spawnSync(process.execPath, [
'--no-warnings',
'--experimental-bench',
'-e',
'require("node:bench").bench("failure", () => { throw new Error(); })',
]);
assert.strictEqual(child.status, 1);
const completion = bench('automatic execution', {
warmup: 0,
}, common.mustCall((b) => {
b.record({ duration_ns: 1n, operations: 1 });
}, 30));
completion.then(common.mustCall((result) => {
assert.strictEqual(result.name, 'automatic execution');
assert.strictEqual(result.samples.length, 30);
assert.strictEqual(result.error, undefined);
assert.strictEqual(result.skip, undefined);
assert.strictEqual(result.summary.mean > 0, true);
}));