Skip to content

Commit a82e0e6

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. PR-URL: #12934 Ref: #12497 Ref: #12433 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 6f449db commit a82e0e6

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)