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

Function main

benchmark/vm/source-text-module-leaf.js:15–84  ·  view source on GitHub ↗
({ stage, type, n })

Source from the content-addressed store, hash-verified

13});
14
15function 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') {

Callers

nothing calls this directly

Calls 9

linkRequestsMethod · 0.80
allMethod · 0.80
finalizeFunction · 0.70
startMethod · 0.45
pushMethod · 0.45
endMethod · 0.45
instantiateMethod · 0.45
evaluateMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…