Skip to content

Commit 591428e

Browse files
committed
fix: benchmark timeout is in ms, also don't print useless info
1 parent 0f172f0 commit 591428e

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/benchmark.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ export async function benchmark(name, options, fn) {
4343
total += diff
4444
if (min === undefined || min > diff) min = diff
4545
if (max === undefined || max < diff) max = diff
46-
if (total >= BigInt(timeout)) break
46+
if (total >= BigInt(timeout) * 10n ** 6n) break
4747
}
4848

4949
const mean = total / BigInt(count)
50-
const rps = 1e9 / Number(mean)
51-
console.log(`${name} x ${fRps(rps)} ops/sec @ ${fTime(mean)}/op (${fTime(min)}..${fTime(max)})`)
50+
let res = `${name} x ${fRps(1e9 / Number(mean))} ops/sec @ ${fTime(mean)}/op`
51+
if (fTime(min) !== fTime(max)) res += ` (${fTime(min)}..${fTime(max)})`
52+
console.log(res)
5253

5354
if (globalThis.gc) for (let i = 0; i < 4; i++) globalThis.gc()
5455
}

0 commit comments

Comments
 (0)