()
| 76 | } |
| 77 | |
| 78 | function 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 | |
| 96 | function fastEval() { |
| 97 | const ce = new ComputeEngine(); |
no test coverage detected