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

Function ceBaseline

test/compute-engine/performance.test.ts:40–57  ·  view source on GitHub ↗
(numRandos: number[])

Source from the content-addressed store, hash-verified

38}
39
40function ceBaseline(numRandos: number[]): number {
41 const ce = new ComputeEngine();
42
43 let randos = numRandos.map((n) => ce.number(n));
44
45 let start = globalThis.performance.now();
46
47 randos = randos.map((n, i) => {
48 // Do some arithmetic calculations
49 if (i % 2 === 0) return n.mul(4).pow(2).div(3).add(n.mul(3).div(2)).add(2);
50 // Trigonometry, log, exp
51 return ce
52 .expr(['Tan', n])
53 .add(ce.expr(['Log', ['Abs', n]]).add(ce.expr(['Exp', n])));
54 });
55
56 return globalThis.performance.now() - start;
57}
58
59function ceBaselineN(numRandos: number[]): number {
60 const ce = new ComputeEngine();

Callers 1

Calls 7

numberMethod · 0.95
exprMethod · 0.95
mapMethod · 0.65
addMethod · 0.65
divMethod · 0.65
powMethod · 0.65
mulMethod · 0.65

Tested by

no test coverage detected