({ stage, type, n })
| 13 | }); |
| 14 | |
| 15 | function main({ stage, type, n }) { |
| 16 | const arr = []; |
| 17 | if (stage === 'all' || stage === 'compile') { |
| 18 | bench.start(); |
| 19 | } |
| 20 | |
| 21 | for (let i = 0; i < n; i++) { |
| 22 | let source = `export const value${i} = 1;`; |
| 23 | if (type === 'async') { |
| 24 | source += `\nawait Promise.resolve();\n`; |
| 25 | } |
| 26 | const m = new vm.SourceTextModule(source); |
| 27 | arr.push(m); |
| 28 | } |
| 29 | |
| 30 | if (stage === 'compile') { |
| 31 | bench.end(n); |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | if (stage === 'link') { |
| 36 | bench.start(); |
| 37 | } |
| 38 | |
| 39 | for (let i = 0; i < n; i++) { |
| 40 | arr[i].linkRequests([]); |
| 41 | } |
| 42 | |
| 43 | if (stage === 'link') { |
| 44 | bench.end(n); |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | if (stage === 'instantiate') { |
| 49 | bench.start(); |
| 50 | } |
| 51 | |
| 52 | for (let i = 0; i < n; i++) { |
| 53 | arr[i].instantiate(); |
| 54 | } |
| 55 | |
| 56 | if (stage === 'instantiate') { |
| 57 | bench.end(n); |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | if (stage === 'evaluate') { |
| 62 | bench.start(); |
| 63 | } |
| 64 | |
| 65 | function finalize() { |
| 66 | bench.end(n); |
| 67 | for (let i = 0; i < n; i++) { |
| 68 | assert.strictEqual(arr[i].namespace[`value${i}`], 1); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | if (type === 'sync') { |
nothing calls this directly
no test coverage detected
searching dependent graphs…