Skip to content

Commit 8b8dc74

Browse files
test: use available minified parser fixture
1 parent 3c4ec9b commit 8b8dc74

1 file changed

Lines changed: 9 additions & 18 deletions

File tree

‎test/benchmarkCases/js-parser-unit/index.bench.mjs‎

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ const typescriptSource = fs.readFileSync(
2929
// "three" import condition resolves to build/three.module.js
3030
const threeEsmPath = fileURLToPath(import.meta.resolve("three"));
3131
const threeEsmSource = fs.readFileSync(threeEsmPath, "utf8");
32-
const threeEsmMinSource = fs.readFileSync(
33-
threeEsmPath.replace(/\.js$/, ".min.js"),
34-
"utf8"
35-
);
3632
// Popular libraries also shipped as devDependencies.
3733
const reactSource = readPkgFile("react", "cjs/react.development.js");
3834
const reactDomSource = readPkgFile("react-dom", "cjs/react-dom.development.js");
3935
const lodashSource = readPkgFile("lodash", "lodash.js");
36+
const lodashMinSource = readPkgFile("lodash", "lodash.min.js");
4037
const lodashEsSource = readPkgFile("lodash-es", "lodash.js");
4138

4239
// Tokenize-only: drive WebpackParser's owned tokenizer to EOF, no AST/walk.
@@ -92,12 +89,9 @@ export default (bench) => {
9289
new JavascriptParser("module").parse(threeEsmSource, {});
9390
}
9491
);
95-
bench.add(
96-
"unit benchmark \"js-parser-unit\", source 'three.module.min.js'",
97-
() => {
98-
new JavascriptParser("module").parse(threeEsmMinSource, {});
99-
}
100-
);
92+
bench.add("unit benchmark \"js-parser-unit\", source 'lodash.min.js'", () => {
93+
new JavascriptParser("auto").parse(lodashMinSource, {});
94+
});
10195
bench.add(
10296
"unit benchmark \"js-parser-unit\", source 'react.development.js'",
10397
() => {
@@ -122,13 +116,10 @@ export default (bench) => {
122116
bench.add('unit benchmark "js-parser-unit", tokenize typescript', () => {
123117
tokenizeJs(typescriptSource, "module");
124118
});
125-
bench.add('unit benchmark "js-parser-unit", tokenize three.module.js', () => {
126-
tokenizeJs(threeEsmSource, "module");
119+
bench.add('unit benchmark "js-parser-unit", tokenize lodash.js', () => {
120+
tokenizeJs(lodashSource, "script");
121+
});
122+
bench.add('unit benchmark "js-parser-unit", tokenize lodash.min.js', () => {
123+
tokenizeJs(lodashMinSource, "script");
127124
});
128-
bench.add(
129-
'unit benchmark "js-parser-unit", tokenize three.module.min.js',
130-
() => {
131-
tokenizeJs(threeEsmMinSource, "module");
132-
}
133-
);
134125
};

0 commit comments

Comments
 (0)