Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add benchmarks for babel-types builders #13874

Merged
merged 1 commit into from Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions benchmark/babel-types/builders/memberExpression.mjs
@@ -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 changes: 21 additions & 0 deletions benchmark/babel-types/builders/stringLiteral.mjs
@@ -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();
2 changes: 2 additions & 0 deletions benchmark/package.json
Expand Up @@ -8,13 +8,15 @@
"@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:*",
"@babel/parser": "workspace:*",
"@babel/preset-env": "workspace:*",
"@babel/preset-flow": "workspace:*",
"@babel/traverse": "workspace:*",
"@babel/types": "workspace:*",
"benchmark": "^2.1.4"
},
"version": "7.15.0"
Expand Down
22 changes: 12 additions & 10 deletions yarn.lock
Expand Up @@ -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"
Expand Down Expand Up @@ -130,13 +140,15 @@ __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:*"
"@babel/parser": "workspace:*"
"@babel/preset-env": "workspace:*"
"@babel/preset-flow": "workspace:*"
"@babel/traverse": "workspace:*"
"@babel/types": "workspace:*"
benchmark: ^2.1.4
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -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"
Expand Down