mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
Signed-off-by: James M Snell <jasnell@gmail.com> Assisted-by: Opencode PR-URL: https://github.com/nodejs/node/pull/65920 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br> Reviewed-By: Xuguang Mei <meixuguang@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
28 lines
869 B
JavaScript
28 lines
869 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', 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);
|
|
}));
|