Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Back parser state
exportedIdentifiers
by set (#13406)
- Loading branch information
Showing
7 changed files
with
57 additions
and
15 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
packages/babel-parser/benchmark/many-named-export/1-length.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,34 @@ | ||
import Benchmark from "benchmark"; | ||
import baseline from "@babel-baseline/parser"; | ||
import current from "../../lib/index.js"; | ||
import { report } from "../util.mjs"; | ||
|
||
const suite = new Benchmark.Suite(); | ||
// All codepoints in [0x4e00, 0x9ffc] are valid identifier name per Unicode 13 | ||
function createInput(length) { | ||
if (length > 0x9ffc - 0x4e00) { | ||
throw new Error( | ||
`Length greater than ${ | ||
0x9ffc - 0x4e00 | ||
} is not supported! Consider modify the \`createInput\`.` | ||
); | ||
} | ||
let source = "export { "; | ||
for (let i = 0; i < length; i++) { | ||
source += String.fromCharCode(0x4e00 + i) + ","; | ||
} | ||
return source + " } from './foo'"; | ||
} | ||
function benchCases(name, implementation, options) { | ||
for (const length of [256, 512, 1024, 2048]) { | ||
const input = createInput(length); | ||
suite.add(`${name} ${length} length-1 named export`, () => { | ||
implementation.parse(input, options); | ||
}); | ||
} | ||
} | ||
|
||
benchCases("baseline", baseline, { sourceType: "module" }); | ||
benchCases("current", current, { sourceType: "module" }); | ||
|
||
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
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