Skip to content

Commit de8c041

Browse files
TrottOlivier Martin
authored andcommitted
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: nodejs#12934 Ref: nodejs#12497 Ref: nodejs#12433 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent f4ff299 commit de8c041

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

benchmark/common.js

Lines changed: 3 additions & 0 deletions
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)