Median time of `MEASURED_RUNS` runs of `fn()`, in ms.
(fn: () => void, warmup = 3)
| 41 | |
| 42 | /** Median time of `MEASURED_RUNS` runs of `fn()`, in ms. */ |
| 43 | function bench(fn: () => void, warmup = 3): number { |
| 44 | for (let i = 0; i < warmup; i++) fn(); |
| 45 | const runs: number[] = []; |
| 46 | for (let i = 0; i < MEASURED_RUNS; i++) { |
| 47 | const t0 = globalThis.performance.now(); |
| 48 | fn(); |
| 49 | runs.push(globalThis.performance.now() - t0); |
| 50 | } |
| 51 | return median(runs); |
| 52 | } |
| 53 | |
| 54 | /** A k-term polynomial-ish LaTeX expression */ |
| 55 | function longSum(k: number): string { |
no test coverage detected