forked from babel/babel
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Improve @babel/types builders (babel#16842)
* perf * perf * add bench
- Loading branch information
1 parent
4ff9408
commit ebe4b7c
Showing
5 changed files
with
1,378 additions
and
444 deletions.
There are no files selected for viewing
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,26 @@ | ||
import { Benchmark, baselineTypes, currentTypes } from "../../util.mjs"; | ||
|
||
const bench = new Benchmark(); | ||
|
||
function benchCases(implementations) { | ||
for (const version in implementations) { | ||
const t = implementations[version]; | ||
const func = t.stringLiteral; | ||
const func2 = t.memberExpression; | ||
const func3 = t.assignmentExpression; | ||
const func4 = t.binaryExpression; | ||
|
||
const id = t.identifier("id"); | ||
const id2 = t.identifier("id2"); | ||
bench.add(`${version} builder`, () => { | ||
func("bar"); | ||
func2(id, id2, /*computed?*/ false /*, optional? missing*/); | ||
func3("=", id, id2); | ||
func4("+", id, id2); | ||
}); | ||
} | ||
} | ||
|
||
benchCases({ baselineTypes, currentTypes }); | ||
|
||
bench.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
Oops, something went wrong.