| 38 | } |
| 39 | |
| 40 | function 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 | |
| 59 | function ceBaselineN(numRandos: number[]): number { |
| 60 | const ce = new ComputeEngine(); |