forked from babel/babel
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Left-value parsing cleanup (babel#17160)
* cleanup * refactor: simplify checkProto implementation * rename test * refactor: avoid second scan in type cast transform * refactor: simplify ts parseConditional The current logic is taken from the flow plugin * add benchmark cases
- Loading branch information
Showing
11 changed files
with
109 additions
and
66 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
benchmark/babel-parser/many-nested-conditional-expressions/bench.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Benchmark from "benchmark"; | ||
import { baselineParser, currentParser, report } from "../../util.mjs"; | ||
|
||
const suite = new Benchmark.Suite(); | ||
function createInput(length) { | ||
return "(" + "x ?".repeat(length) + "0" + ": x".repeat(length) + ");"; | ||
} | ||
function benchCases(name, implementation, options) { | ||
for (const length of [256, 512, 1024, 2048]) { | ||
const input = createInput(length); | ||
suite.add(`${name} ${length} nested conditional expressions`, () => { | ||
implementation.parse(input, options); | ||
}); | ||
} | ||
} | ||
|
||
benchCases("baseline", baselineParser); | ||
benchCases("current", currentParser); | ||
|
||
suite.on("cycle", report).run(); |
23 changes: 23 additions & 0 deletions
23
benchmark/babel-parser/many-nested-conditional-expressions/with-typescript-plugin.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Benchmark from "benchmark"; | ||
import { baselineParser, currentParser, report } from "../../util.mjs"; | ||
|
||
const suite = new Benchmark.Suite(); | ||
function createInput(length) { | ||
return "(" + "x ?".repeat(length) + "0" + ": x".repeat(length) + ");"; | ||
} | ||
function benchCases(name, implementation, options) { | ||
for (const length of [256, 512, 1024, 2048]) { | ||
const input = createInput(length); | ||
suite.add( | ||
`${name} ${length} nested conditional expressions with typescript plugin`, | ||
() => { | ||
implementation.parse(input, options); | ||
} | ||
); | ||
} | ||
} | ||
|
||
benchCases("baseline", baselineParser, { plugins: ["typescript"] }); | ||
benchCases("current", currentParser, { plugins: ["typescript"] }); | ||
|
||
suite.on("cycle", report).run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ges/babel-parser/test/fixtures/typescript/async-call/with-optional-parameter/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"throws": "Unexpected token (1:8)" | ||
} | ||
"throws": "Unexpected token (1:7)" | ||
} |