Skip to content

Commit e990319

Browse files
test(benchmark): measure the parse a build asks for, not one nobody asks for
The `mode 'parse'` row says it passes the same options as `parse()` and then asks for locations, which `parse()` never does — it derives line and column from node offsets. That went unnoticed while the parser dropped locations on the lazy path: asking cost nothing because nothing was tracked. Now that a caller asking for locations gets them, the row measures 8.9 MB of location objects (451 ms to 2131 ms here) that no build pays for.
1 parent aada3d9 commit e990319

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ export default (bench) => {
7373
new JavascriptParser("script").parse(typescriptSource, {});
7474
});
7575

76-
// acorn only, no walk; same options as parse() to isolate walker changes
76+
// acorn only, no walk, and the options `parse()` really passes: it derives
77+
// line and column from offsets, so tracking them here measures nobody's build.
7778
bench.add("unit benchmark \"js-parser-unit\", mode 'parse'", () => {
7879
JavascriptParser._parse(typescriptSource, {
7980
sourceType: "auto",
80-
locations: true,
81+
locations: false,
8182
ranges: true,
8283
comments: true,
8384
importPhases: false

0 commit comments

Comments
 (0)