mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
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>
30 lines
887 B
JavaScript
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);
|
|
}));
|