mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
18 lines
504 B
JavaScript
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);
|