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

Function main

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

Source from the content-addressed store, hash-verified

16);
17
18function main({ operation, n }) {
19 const Module = require('node:module');
20
21 Module.setSourceMapsSupport(true, {
22 generatedCode: true,
23 });
24 const validFileName = fixtures.path('test-runner/source-maps/line-lengths/index.js');
25
26 const fileNameKey = '/source-map/disk.js';
27 const generatedFileName = fixtures.path(fileNameKey);
28 const generatedFileContent = fixtures.readSync(fileNameKey, 'utf8');
29 const sourceMapUrl = generatedFileName.replace(/\.js$/, '.map');
30 const sourceWithGeneratedSourceMap =
31 `${generatedFileContent}\n//# sourceMappingURL=${sourceMapUrl}\n//# sourceURL=${generatedFileName}`;
32 const generatedExpectedUrl = `file://${generatedFileName}`;
33
34 let sourceMap;
35 switch (operation) {
36 case 'findSourceMap-valid':
37 require(validFileName);
38
39 bench.start();
40 for (let i = 0; i < n; i++) {
41 sourceMap = Module.findSourceMap(validFileName);
42 }
43 bench.end(n);
44 break;
45
46 case 'findSourceMap-generated-source':
47 eval(sourceWithGeneratedSourceMap);
48
49 bench.start();
50 for (let i = 0; i < n; i++) {
51 sourceMap = Module.findSourceMap(generatedExpectedUrl);
52 }
53 bench.end(n);
54 break;
55
56 default:
57 throw new Error(`Unknown operation: ${operation}`);
58 }
59 assert.ok(sourceMap);
60}

Callers

nothing calls this directly

Calls 7

requireFunction · 0.50
evalFunction · 0.50
pathMethod · 0.45
readSyncMethod · 0.45
startMethod · 0.45
endMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…