Skip to content

Commit b6a9857

Browse files
committed
fix: better benchmark rps calculation when very fast
1 parent 8c48e08 commit b6a9857

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export async function benchmark(name, options, fn) {
5353
}
5454

5555
const mean = total / BigInt(count)
56-
const rps = 1e9 / Number(mean)
56+
const rps = (1e9 * count) / Number(total) // Loss in precision to doubles on very fast ops, but this is better than mean rounding
5757
let res = `${name} x ${fRps(rps)} ops/sec @ ${fTime(mean)}/op`
5858
if (fTime(min) !== fTime(max)) res += ` (${fTime(min)}..${fTime(max)})`
5959
console.log(res)

0 commit comments

Comments
 (0)