MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / timeit

Function timeit

benchmarks/audit/wester.ts:121–127  ·  view source on GitHub ↗
(fn: () => void)

Source from the content-addressed store, hash-verified

119
120function 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; }
121function 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 --------------------------------------
130type 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 };

Callers 1

runOnFunction · 0.70

Calls 3

fnFunction · 0.85
medianFunction · 0.70
roundMethod · 0.45

Tested by

no test coverage detected