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

Function timeit

benchmarks/runners/run_ce_rubi.mjs:111–120  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

109 return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2;
110}
111function timeit(fn) {
112 let t = performance.now();
113 fn();
114 const first = performance.now() - t;
115 const iterations = Math.min(50, Math.max(1, Math.round(150 / Math.max(first, 0.01))));
116 for (let i = 0; i < Math.min(3, iterations); i++) fn();
117 const times = [];
118 for (let i = 0; i < iterations; i++) { t = performance.now(); fn(); times.push(performance.now() - t); }
119 return { timeMs: median(times), minMs: Math.min(...times), iterations };
120}
121const num = (boxed) => {
122 const v = boxed.N();
123 return typeof v.re === 'number' ? v.re : Number(v.toString());

Callers 1

runCaseFunction · 0.70

Calls 3

fnFunction · 0.85
medianFunction · 0.70
roundMethod · 0.45

Tested by

no test coverage detected