add benchmarks for babel-types builders (#13874)
This commit is contained in:
parent
b5907ef967
commit
76a7e65229
23
benchmark/babel-types/builders/memberExpression.mjs
Normal file
23
benchmark/babel-types/builders/memberExpression.mjs
Normal file
@ -0,0 +1,23 @@
|
||||
import Benchmark from "benchmark";
|
||||
import baseline from "@babel-baseline/types";
|
||||
import current from "@babel/types";
|
||||
import { report } from "../../util.mjs";
|
||||
|
||||
const suite = new Benchmark.Suite();
|
||||
|
||||
function benchCases(implementations) {
|
||||
const funcName = "memberExpression";
|
||||
for (const version in implementations) {
|
||||
const t = implementations[version];
|
||||
const func = t[funcName];
|
||||
const idObj = t.identifier("obj");
|
||||
const idProp = t.identifier("prop");
|
||||
suite.add(`${version} ${funcName} builder`, () => {
|
||||
func(idObj, idProp, /*computed?*/ false, /*optional? missing*/);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
benchCases({ baseline, current });
|
||||
|
||||
suite.on("cycle", report).run();
|
||||
21
benchmark/babel-types/builders/stringLiteral.mjs
Normal file
21
benchmark/babel-types/builders/stringLiteral.mjs
Normal file
@ -0,0 +1,21 @@
|
||||
import Benchmark from "benchmark";
|
||||
import baseline from "@babel-baseline/types";
|
||||
import current from "@babel/types";
|
||||
import { report } from "../../util.mjs";
|
||||
|
||||
const suite = new Benchmark.Suite();
|
||||
|
||||
function benchCases(implementations) {
|
||||
const funcName = "stringLiteral";
|
||||
for (const version in implementations) {
|
||||
const t = implementations[version];
|
||||
const func = t[funcName];
|
||||
suite.add(`${version} ${funcName} builder`, () => {
|
||||
func("bar");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
benchCases({ baseline, current });
|
||||
|
||||
suite.on("cycle", report).run();
|
||||
@ -8,6 +8,7 @@
|
||||
"@babel-baseline/helper-validator-identifier": "npm:@babel/helper-validator-identifier@7.10.4",
|
||||
"@babel-baseline/parser": "npm:@babel/parser@7.14.8",
|
||||
"@babel-baseline/traverse": "npm:@babel/traverse@7.15.4",
|
||||
"@babel-baseline/types": "npm:@babel/types@7.15.6",
|
||||
"@babel/core": "workspace:*",
|
||||
"@babel/generator": "workspace:*",
|
||||
"@babel/helper-validator-identifier": "workspace:*",
|
||||
@ -15,6 +16,7 @@
|
||||
"@babel/preset-env": "workspace:*",
|
||||
"@babel/preset-flow": "workspace:*",
|
||||
"@babel/traverse": "workspace:*",
|
||||
"@babel/types": "workspace:*",
|
||||
"benchmark": "^2.1.4"
|
||||
},
|
||||
"version": "7.15.0"
|
||||
|
||||
22
yarn.lock
22
yarn.lock
@ -72,6 +72,16 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@babel-baseline/types@npm:@babel/types@7.15.6, @babel/types@npm:^7.0.0, @babel/types@npm:^7.12.7, @babel/types@npm:^7.14.5, @babel/types@npm:^7.15.0, @babel/types@npm:^7.15.4, @babel/types@npm:^7.15.6, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4":
|
||||
version: 7.15.6
|
||||
resolution: "@babel/types@npm:7.15.6"
|
||||
dependencies:
|
||||
"@babel/helper-validator-identifier": ^7.14.9
|
||||
to-fast-properties: ^2.0.0
|
||||
checksum: 37f497dde10d238b5eb184efab83b415a86611e3d73dc0434de0cfb851b20ee606a3b7e1525e5b2d522fac1248d0345fea0468006f246262511b80cd3ed2419f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@babel-internal/runtime-integration-rollup@workspace:test/runtime-integration/rollup":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@babel-internal/runtime-integration-rollup@workspace:test/runtime-integration/rollup"
|
||||
@ -130,6 +140,7 @@ __metadata:
|
||||
"@babel-baseline/helper-validator-identifier": "npm:@babel/helper-validator-identifier@7.10.4"
|
||||
"@babel-baseline/parser": "npm:@babel/parser@7.14.8"
|
||||
"@babel-baseline/traverse": "npm:@babel/traverse@7.15.4"
|
||||
"@babel-baseline/types": "npm:@babel/types@7.15.6"
|
||||
"@babel/core": "workspace:*"
|
||||
"@babel/generator": "workspace:*"
|
||||
"@babel/helper-validator-identifier": "workspace:*"
|
||||
@ -137,6 +148,7 @@ __metadata:
|
||||
"@babel/preset-env": "workspace:*"
|
||||
"@babel/preset-flow": "workspace:*"
|
||||
"@babel/traverse": "workspace:*"
|
||||
"@babel/types": "workspace:*"
|
||||
benchmark: ^2.1.4
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
@ -3600,16 +3612,6 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@babel/types@npm:^7.0.0, @babel/types@npm:^7.12.7, @babel/types@npm:^7.14.5, @babel/types@npm:^7.15.0, @babel/types@npm:^7.15.4, @babel/types@npm:^7.15.6, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.4":
|
||||
version: 7.15.6
|
||||
resolution: "@babel/types@npm:7.15.6"
|
||||
dependencies:
|
||||
"@babel/helper-validator-identifier": ^7.14.9
|
||||
to-fast-properties: ^2.0.0
|
||||
checksum: 37f497dde10d238b5eb184efab83b415a86611e3d73dc0434de0cfb851b20ee606a3b7e1525e5b2d522fac1248d0345fea0468006f246262511b80cd3ed2419f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@babel/types@workspace:*, @babel/types@workspace:^7.14.9, @babel/types@workspace:^7.15.4, @babel/types@workspace:^7.15.6, @babel/types@workspace:packages/babel-types":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@babel/types@workspace:packages/babel-types"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user