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

Function slowEval

test/compute-engine/performance.test.ts:78–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76}
77
78function slowEval() {
79 const ce = new ComputeEngine();
80
81 const expr = ce.parse('ax^2+bx+c')!; // like $$ ax^2+bx+c $$
82 const vars = { a: 2, b: 3, c: 4 };
83
84 ce.precision = 'auto';
85 ce.strict = true;
86
87 let y = 0;
88 const startTime = performance.now();
89 for (let x = 0; x <= Math.PI; x += 0.01) {
90 y += Number(expr.subs(vars).subs({ x }).N().re);
91 }
92
93 return performance.now() - startTime;
94}
95
96function fastEval() {
97 const ce = new ComputeEngine();

Callers 1

Calls 3

parseMethod · 0.95
NMethod · 0.65
subsMethod · 0.65

Tested by

no test coverage detected