Skip to content

Commit 90a4a43

Browse files
committed
benchmark: check for time precision in common.js
Some benchmark tests are failing intermittently, possibly due to hrtime() imprecision on particular hosts. This change will confirm or refute that as the root cause the next time the test fails on CI. Either way, it's a valid check. Refs: nodejs#12497 Refs: nodejs#12433
1 parent faf6654 commit 90a4a43

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

benchmark/common.js

+3
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ Benchmark.prototype.end = function(operations) {
196196
if (!process.env.NODEJS_BENCHMARK_ZERO_ALLOWED && operations <= 0) {
197197
throw new Error('called end() with operation count <= 0');
198198
}
199+
if (elapsed[0] === 0 && elapsed[1] === 0) {
200+
throw new Error('insufficient time precision for short benchmark');
201+
}
199202

200203
const time = elapsed[0] + elapsed[1] / 1e9;
201204
const rate = operations / time;

0 commit comments

Comments
 (0)