MCPcopy Index your code
hub / github.com/nodejs/node / main

Function main

benchmark/vm/source-text-module-flat.js:14–68  ·  view source on GitHub ↗
({ stage, n })

Source from the content-addressed store, hash-verified

12});
13
14function main({ stage, n }) {
15 const arr = [];
16 let importSource = '';
17 let useSource = 'export const result = 0 ';
18 for (let i = 0; i < n; i++) {
19 importSource += `import { value${i} } from 'mod${i}';\n`;
20 useSource += ` + value${i}\n`;
21 }
22
23 if (stage === 'all') {
24 bench.start();
25 }
26 for (let i = 0; i < n; i++) {
27 const m = new vm.SourceTextModule(`
28 export const value${i} = 1;
29 `);
30 arr.push(m);
31 }
32
33 const root = new vm.SourceTextModule(`
34 ${importSource}
35 ${useSource};
36 `);
37
38 if (stage === 'link') {
39 bench.start();
40 }
41
42 root.linkRequests(arr);
43 for (let i = 0; i < n; i++) {
44 arr[i].linkRequests([]);
45 }
46
47 if (stage === 'link') {
48 bench.end(n);
49 }
50
51 if (stage === 'instantiate') {
52 bench.start();
53 }
54 root.instantiate();
55 if (stage === 'instantiate') {
56 bench.end(n);
57 }
58
59 if (stage === 'evaluate') {
60 bench.start();
61 }
62 root.evaluate();
63 if (stage === 'evaluate' || stage === 'all') {
64 bench.end(n);
65 }
66
67 assert.strictEqual(root.namespace.result, n);
68}

Callers

nothing calls this directly

Calls 6

linkRequestsMethod · 0.95
instantiateMethod · 0.95
startMethod · 0.45
pushMethod · 0.45
endMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…