node/test/parallel/test-perf-hooks-timerify-histogram-async.mjs
Joyee Cheung b4b1413779
test: split test-perf-hooks-timerify
This test has been flaky in the CI. It squeezes too many independent
test cases into one file, so split it up so that we can mark the
persistent flaky test case and leave the unproblematic ones alone.

PR-URL: https://github.com/nodejs/node/pull/60568
Refs: https://github.com/nodejs/node/issues/54803
Refs: https://github.com/nodejs/reliability/blob/main/reports/2025-11-03.md
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2025-11-05 15:19:04 +00:00

18 lines
504 B
JavaScript

// Test that timerify works with histogram option for asynchronous functions.
import '../common/index.mjs';
import assert from 'assert';
import { createHistogram, timerify } from 'perf_hooks';
import { setTimeout as sleep } from 'timers/promises';
const histogram = createHistogram();
const m = async (a, b = 1) => {
await sleep(10);
};
const n = timerify(m, { histogram });
assert.strictEqual(histogram.max, 0);
for (let i = 0; i < 10; i++) {
await n();
}
assert.notStrictEqual(histogram.max, 0);