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

Function ceBaselineN

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

Source from the content-addressed store, hash-verified

57}
58
59function ceBaselineN(numRandos: number[]): number {
60 const ce = new ComputeEngine();
61
62 let randos = numRandos.map((n) => ce.number(n));
63
64 let start = globalThis.performance.now();
65
66 randos = randos.map((n, i) => {
67 // Do some arithmetic calculations
68 if (i % 2 === 0)
69 return n.mul(4).pow(2).div(3).add(n.mul(3).div(2)).add(2).N();
70
71 // Trigonometry, log, exp
72 return ce.expr(['Add', ['Tan', n], ['Log', ['Abs', n]], ['Exp', n]]).N();
73 });
74
75 return globalThis.performance.now() - start;
76}
77
78function slowEval() {
79 const ce = new ComputeEngine();

Callers 1

Calls 8

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

Tested by

no test coverage detected