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>
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
// Flags: --experimental-bench --no-warnings
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { completeSample } = require('../common/bench');
|
|
const assert = require('assert');
|
|
const { createRunner } = require('node:bench');
|
|
|
|
// Benchmarks that do not set `warmup` run ten unreported invocations before
|
|
// the measured samples.
|
|
(async () => {
|
|
const runner = createRunner({ yieldBetweenSamples: false });
|
|
const phases = [];
|
|
|
|
const completion = runner.bench('default warmup', {
|
|
samples: 2,
|
|
}, common.mustCall((b) => {
|
|
phases.push(b.phase);
|
|
completeSample(b);
|
|
}, 12));
|
|
|
|
const records = await runner.run().toArray();
|
|
const result = await completion;
|
|
|
|
const plan = records.find(({ type }) => type === 'bench:plan').data;
|
|
assert.strictEqual(plan.warmup, 10);
|
|
assert.deepStrictEqual(phases, [
|
|
...Array(10).fill('warmup'),
|
|
'measurement',
|
|
'measurement',
|
|
]);
|
|
assert.strictEqual(result.samples.length, 2);
|
|
assert.strictEqual(
|
|
records.filter(({ type }) => type === 'bench:sample').length, 2);
|
|
})().then(common.mustCall());
|