| 119 | |
| 120 | function median(xs: number[]) { const s = [...xs].sort((a, b) => a - b); const m = Math.floor(s.length / 2); return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2; } |
| 121 | function timeit(fn: () => void) { |
| 122 | let t = performance.now(); fn(); |
| 123 | const iters = Math.min(15, Math.max(1, Math.round(60 / Math.max(performance.now() - t, 0.01)))); |
| 124 | const times: number[] = []; |
| 125 | for (let i = 0; i < iters; i++) { t = performance.now(); fn(); times.push(performance.now() - t); } |
| 126 | return median(times); |
| 127 | } |
| 128 | |
| 129 | // --- load + categorize runnable cases -------------------------------------- |
| 130 | type Case = { id: string; file: string; cat: string; op: string; arg: any; varName: string; sympyExpr: string; arg2?: any; sympyExpr2?: string; point?: any; a?: any; b?: any; tol: number }; |