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

Function jsBaseline

test/compute-engine/performance.test.ts:27–38  ·  view source on GitHub ↗

Establish a baseline for computation performance in JS. * Compute Engine calculations will be measured against this.

(randos: number[])

Source from the content-addressed store, hash-verified

25 * Compute Engine calculations will be measured against this.
26 */
27function jsBaseline(randos: number[]): number {
28 let start = globalThis.performance.now();
29 for (let i = 0; i < 20; i++) {
30 randos = randos.map((n, i) => {
31 // Do some arithmetic calculations
32 if (i % 2 === 0) return (4 * n ** 2) / 3 + (3 * n) / 2 + 2;
33 // Trigonometry, log, exp
34 return Math.tan(n) + Math.log(Math.abs(n)) + Math.exp(n);
35 });
36 }
37 return (globalThis.performance.now() - start) / 20;
38}
39
40function ceBaseline(numRandos: number[]): number {
41 const ce = new ComputeEngine();

Callers 1

Calls 5

tanMethod · 0.80
mapMethod · 0.65
logMethod · 0.65
absMethod · 0.65
expMethod · 0.65

Tested by

no test coverage detected