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

Function main

benchmark/source_map/source-map.js:22–95  ·  view source on GitHub ↗
({ operation, n })

Source from the content-addressed store, hash-verified

20);
21
22function main({ operation, n }) {
23 const { SourceMap } = require('node:module');
24
25 const samplePayload = JSON.parse(
26 fixtures.readSync('source-map/no-source.js.map', 'utf8'),
27 );
28 const sectionedPayload = JSON.parse(
29 fixtures.readSync('source-map/disk-index.map', 'utf8'),
30 );
31
32 let sourceMap;
33 let sourceMapMethod;
34 switch (operation) {
35 case 'parse':
36 bench.start();
37 for (let i = 0; i < n; i++) {
38 sourceMap = new SourceMap(samplePayload);
39 }
40 bench.end(n);
41 break;
42
43 case 'parse-sectioned':
44 bench.start();
45 for (let i = 0; i < n; i++) {
46 sourceMap = new SourceMap(sectionedPayload);
47 }
48 bench.end(n);
49 break;
50
51 case 'findEntry':
52 sourceMap = new SourceMap(samplePayload);
53 bench.start();
54 for (let i = 0; i < n; i++) {
55 sourceMapMethod = sourceMap.findEntry(i, i);
56 }
57 bench.end(n);
58 assert.ok(sourceMapMethod);
59 break;
60
61 case 'findEntry-sectioned':
62 sourceMap = new SourceMap(sectionedPayload);
63 bench.start();
64 for (let i = 0; i < n; i++) {
65 sourceMapMethod = sourceMap.findEntry(i, i);
66 }
67 bench.end(n);
68 assert.ok(sourceMapMethod);
69 break;
70
71 case 'findOrigin':
72 sourceMap = new SourceMap(samplePayload);
73 bench.start();
74 for (let i = 0; i < n; i++) {
75 sourceMapMethod = sourceMap.findOrigin(i, i);
76 }
77 bench.end(n);
78 assert.ok(sourceMapMethod);
79 break;

Callers

nothing calls this directly

Calls 8

findOriginMethod · 0.80
parseMethod · 0.65
requireFunction · 0.50
readSyncMethod · 0.45
startMethod · 0.45
endMethod · 0.45
findEntryMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…