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

Function bench

test/compute-engine/benchmarks/parse.benchmark.test.ts:43–52  ·  view source on GitHub ↗

Median time of `MEASURED_RUNS` runs of `fn()`, in ms.

(fn: () => void, warmup = 3)

Source from the content-addressed store, hash-verified

41
42/** Median time of `MEASURED_RUNS` runs of `fn()`, in ms. */
43function 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 */
55function longSum(k: number): string {

Callers 1

Calls 2

fnFunction · 0.85
medianFunction · 0.70

Tested by

no test coverage detected