Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore traversal context after enter / traverse (#13813)
- Loading branch information
Showing
10 changed files
with
3,353 additions
and
143 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
benchmark/babel-core/real-case-preset-env-flow/babel-parser-expression.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,42 @@ | ||
import Benchmark from "benchmark"; | ||
import baseline from "@babel-baseline/core"; | ||
import current from "@babel/core"; | ||
import parser from "@babel-baseline/parser"; | ||
import { report } from "../../util.mjs"; | ||
import { readFileSync } from "fs"; | ||
|
||
const suite = new Benchmark.Suite(); | ||
const fixtureName = "babel-parser-expression.txt"; | ||
|
||
function createInput() { | ||
return parser.parse( | ||
readFileSync(new URL("./" + fixtureName, import.meta.url), { | ||
encoding: "utf-8", | ||
}), | ||
{ sourceType: "module", plugins: ["flow"] } | ||
); | ||
} | ||
function benchCases(name, implementation, options) { | ||
const input = createInput(); | ||
suite.add( | ||
`${name} ${fixtureName}`, | ||
() => { | ||
implementation(input, { | ||
plugins: ["@babel/preset-env", "@babel/preset-flow"], | ||
targets: "ie 11", | ||
configFile: false, | ||
babelrc: false, | ||
...options, | ||
}); | ||
}, | ||
{ | ||
// increase minSamples for accuracy | ||
minSamples: 100, | ||
} | ||
); | ||
} | ||
|
||
benchCases("baseline", baseline.transformFromAstSync, {}); | ||
benchCases("current", current.transformFromAstSync, {}); | ||
|
||
suite.on("cycle", report).run(); |
Oops, something went wrong.