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

Function timeit

benchmarks/audit/audit.ts:40–47  ·  view source on GitHub ↗
(fn: () => void)

Source from the content-addressed store, hash-verified

38 return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2;
39}
40function timeit(fn: () => void) {
41 let t = performance.now(); fn();
42 const first = performance.now() - t;
43 const iters = Math.min(30, Math.max(1, Math.round(120 / Math.max(first, 0.01))));
44 const times: number[] = [];
45 for (let i = 0; i < iters; i++) { t = performance.now(); fn(); times.push(performance.now() - t); }
46 return { timeMs: median(times), minMs: Math.min(...times) };
47}
48const num = (b: any) => { const v = b.N(); return typeof v.re === 'number' ? v.re : Number(v.toString()); };
49// Sample points are scalars (univariate, substituted for x) or tuples matching
50// the case's `verify.vars` (multivariate — all variables substituted at once).

Callers 1

runCEFunction · 0.70

Calls 3

fnFunction · 0.85
medianFunction · 0.70
roundMethod · 0.45

Tested by

no test coverage detected