Commit 147ade5ff9f for nodejs
commit 147ade5ff9fb3afcd1284491d6db348bedef35e6
Author: James M Snell <jasnell@gmail.com>
Date: Fri Sep 25 04:14:54 2026 +0000
test: deflake sliding window histogram test
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66132
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
diff --git a/test/parallel/test-perf-hooks-sliding-window-histogram.js b/test/parallel/test-perf-hooks-sliding-window-histogram.js
index e8939e769a1..db0d0bc7bf8 100644
--- a/test/parallel/test-perf-hooks-sliding-window-histogram.js
+++ b/test/parallel/test-perf-hooks-sliding-window-histogram.js
@@ -176,8 +176,12 @@ const {
}
(async () => {
+ // Chunk generations are aligned to the histogram's creation time. Use two
+ // chunks so that a chunk boundary falling between record() and snapshot()
+ // cannot drop the freshly recorded value, and wait for a duration that is
+ // not a multiple of chunkDuration so the wakeup does not land on a boundary.
const histogram = createSlidingWindowHistogram({
- chunks: 1,
+ chunks: 2,
chunkDuration: 100,
highest: 100,
});
@@ -185,7 +189,7 @@ const {
histogram.record(1);
assert.strictEqual(histogram.snapshot().count, 1);
- await delay(common.platformTimeout(200));
+ await delay(common.platformTimeout(250));
assert.strictEqual(histogram.snapshot().count, 0);
histogram.record(2);