mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: https://github.com/nodejs/node/pull/66534 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Bryan English <bryan@bryanenglish.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
26 lines
788 B
JavaScript
26 lines
788 B
JavaScript
// Flags: --experimental-bench --no-warnings
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const originalHrtimeBigint = process.hrtime.bigint;
|
|
process.hrtime.bigint = () => 1n;
|
|
const { bench, run } = require('node:bench');
|
|
process.hrtime.bigint = originalHrtimeBigint;
|
|
|
|
const completion = bench('zero duration', { samples: 1 }, (b) => {
|
|
b.start();
|
|
b.end(1);
|
|
});
|
|
|
|
(async () => {
|
|
await run().toArray();
|
|
const result = await completion;
|
|
assert.strictEqual(result.error.code, 'ERR_INVALID_STATE');
|
|
assert.match(result.error.message, /insufficient clock precision/);
|
|
// The failed run sets the exit code; reset it so the test itself passes.
|
|
assert.strictEqual(process.exitCode, 1);
|
|
process.exitCode = 0;
|
|
})().then(common.mustCall());
|