Skip to content

Commit 147ade5

Browse files
committed
test: deflake sliding window histogram test
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #66132 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent d196094 commit 147ade5

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎test/parallel/test-perf-hooks-sliding-window-histogram.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,20 @@ const {
176176
}
177177

178178
(async () => {
179+
// Chunk generations are aligned to the histogram's creation time. Use two
180+
// chunks so that a chunk boundary falling between record() and snapshot()
181+
// cannot drop the freshly recorded value, and wait for a duration that is
182+
// not a multiple of chunkDuration so the wakeup does not land on a boundary.
179183
const histogram = createSlidingWindowHistogram({
180-
chunks: 1,
184+
chunks: 2,
181185
chunkDuration: 100,
182186
highest: 100,
183187
});
184188

185189
histogram.record(1);
186190
assert.strictEqual(histogram.snapshot().count, 1);
187191

188-
await delay(common.platformTimeout(200));
192+
await delay(common.platformTimeout(250));
189193
assert.strictEqual(histogram.snapshot().count, 0);
190194

191195
histogram.record(2);

0 commit comments

Comments
 (0)