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

Function main

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

Source from the content-addressed store, hash-verified

12});
13
14function main({ stage, n }) {
15 const arr = [new vm.SourceTextModule(`
16 export const value = 42;
17 `)];
18
19 if (stage === 'all') {
20 bench.start();
21 }
22
23 for (let i = 0; i < n; i++) {
24 const m = new vm.SourceTextModule(`
25 export { value } from 'mod${i}';
26 `);
27 arr.push(m);
28 m.linkRequests([arr[i]]);
29 }
30
31 if (stage === 'instantiate') {
32 bench.start();
33 }
34 arr[n].instantiate();
35 if (stage === 'instantiate') {
36 bench.end(n);
37 }
38
39 if (stage === 'evaluate') {
40 bench.start();
41 }
42 arr[n].evaluate();
43 if (stage === 'evaluate' || stage === 'all') {
44 bench.end(n);
45 }
46
47 assert.strictEqual(arr[n].namespace.value, 42);
48}

Callers

nothing calls this directly

Calls 6

linkRequestsMethod · 0.95
startMethod · 0.45
pushMethod · 0.45
instantiateMethod · 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…