Skip to content

Commit 02b5acc

Browse files
benchmark: remove internal source map caching
1 parent 2486aaf commit 02b5acc

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

benchmark/source_map/source-map-cache.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const common = require('../common.js');
44
const assert = require('assert');
5-
const fs = require('fs');
65
const path = require('path');
76

87
const options = {
@@ -22,24 +21,28 @@ const bench = common.createBenchmark(
2221
);
2322

2423
function main({ operation, n }) {
25-
const {
26-
maybeCacheSourceMap,
27-
} = require('internal/source_map/source_map_cache');
2824
const Module = require('node:module');
2925

3026
Module.setSourceMapsSupport(true);
3127
const validFileName = path.resolve(
3228
__dirname,
3329
'../../test/fixtures/test-runner/source-maps/line-lengths/index.js',
3430
);
35-
const validMapFile = path.resolve(validFileName + '.map');
36-
const validFileContent = fs.readFileSync(validFileName, 'utf8');
37-
const fakeModule = { filename: validFileName };
31+
32+
const sourceWithGeneratedSourceMap = `
33+
console.log("Hello from generated source");
34+
function test() {
35+
return 42;
36+
}
37+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUFDQTtBQUNBO0FBQ0EiLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZXNDb250ZW50IjpbImNvbnNvbGUubG9nKFwiSGVsbG8gZnJvbSBnZW5lcmF0ZWQgc291cmNlXCIpO1xuZnVuY3Rpb24gdGVzdCgpIHtcbiAgcmV0dXJuIDQyO1xufSJdfQ==
38+
//# sourceURL=test-generated-source.js
39+
`;
40+
const expectedUrl = `file://${path.resolve('test-generated-source.js')}`;
3841

3942
let sourceMap;
4043
switch (operation) {
4144
case 'findSourceMap-valid':
42-
maybeCacheSourceMap(validFileName, validFileContent, fakeModule, false, undefined, validMapFile);
45+
require(validFileName);
4346
bench.start();
4447

4548
for (let i = 0; i < n; i++) {
@@ -49,18 +52,11 @@ function main({ operation, n }) {
4952
break;
5053

5154
case 'findSourceMap-generated-source':
52-
maybeCacheSourceMap(
53-
validFileName,
54-
validFileContent,
55-
fakeModule,
56-
true,
57-
validFileName,
58-
validMapFile,
59-
);
60-
bench.start();
55+
eval(sourceWithGeneratedSourceMap);
6156

57+
bench.start();
6258
for (let i = 0; i < n; i++) {
63-
sourceMap = Module.findSourceMap(validFileName);
59+
sourceMap = Module.findSourceMap(expectedUrl);
6460
}
6561
bench.end(n);
6662
break;

0 commit comments

Comments
 (0)