chore: reorganize benchmarks (#13606)

This commit is contained in:
Huáng Jùnliàng 2021-07-28 07:10:29 -04:00 committed by GitHub
parent d1f908924c
commit e4de256cdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 101 additions and 119 deletions

View File

@ -1,8 +1,8 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/generator";
import current from "../../lib/index.js";
import current from "@babel/generator";
import parser from "@babel/parser";
import { report } from "../util.mjs";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();

View File

@ -1,8 +1,8 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/generator";
import current from "../../lib/index.js";
import current from "@babel/generator";
import parser from "@babel/parser";
import { report } from "../util.mjs";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();

View File

@ -1,8 +1,8 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/generator";
import current from "../../lib/index.js";
import current from "@babel/generator";
import parser from "@babel/parser";
import { report } from "../util.mjs";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();

View File

@ -1,8 +1,8 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/generator";
import current from "../../lib/index.js";
import current from "@babel/generator";
import parser from "@babel/parser";
import { report } from "../util.mjs";
import { report } from "../../util.mjs";
import { readFileSync } from "fs";
const suite = new Benchmark.Suite();

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel/helper-validator-identifier-baseline";
import current from "../lib/index.js";
import { report } from "./util.mjs";
import baseline from "@babel-baseline/helper-validator-identifier";
import current from "@babel/helper-validator-identifier";
import { report } from "../util.mjs";
const suite = new Benchmark.Suite();

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel/helper-validator-identifier-baseline";
import current from "../lib/index.js";
import { report } from "./util.mjs";
import baseline from "@babel-baseline/helper-validator-identifier";
import current from "@babel/helper-validator-identifier";
import { report } from "../util.mjs";
const suite = new Benchmark.Suite();

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel/helper-validator-identifier-baseline";
import current from "../lib/index.js";
import { report } from "./util.mjs";
import baseline from "@babel-baseline/helper-validator-identifier";
import current from "@babel/helper-validator-identifier";
import { report } from "../util.mjs";
const suite = new Benchmark.Suite();

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel/helper-validator-identifier-baseline";
import current from "../lib/index.js";
import { report } from "./util.mjs";
import baseline from "@babel-baseline/helper-validator-identifier";
import current from "@babel/helper-validator-identifier";
import { report } from "../util.mjs";
const suite = new Benchmark.Suite();

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel/helper-validator-identifier-baseline";
import current from "../lib/index.js";
import { report } from "./util.mjs";
import baseline from "@babel-baseline/helper-validator-identifier";
import current from "@babel/helper-validator-identifier";
import { report } from "../util.mjs";
const suite = new Benchmark.Suite();

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
// All codepoints in [0x4e00, 0x9ffc] are valid identifier name per Unicode 13

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "../../lib/index-main.js";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "../../lib/index-main.js";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
// All codepoints in [0x4e00, 0x9ffc] are valid identifier name per Unicode 13

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
// All codepoints in [0x4e00, 0x9ffc] are valid identifier name per Unicode 13

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "../../lib/index-v2.js";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

View File

@ -1,7 +1,7 @@
import Benchmark from "benchmark";
import baseline from "@babel-baseline/parser";
import current from "../../lib/index.js";
import { report } from "../util.mjs";
import current from "@babel/parser";
import { report } from "../../util.mjs";
const suite = new Benchmark.Suite();
function createInput(length) {

14
benchmark/package.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "@babel/benchmark",
"private": true,
"type": "module",
"devDependencies": {
"@babel-baseline/generator": "npm:@babel/generator@7.14.5",
"@babel-baseline/helper-validator-identifier": "npm:@babel/helper-validator-identifier@7.10.4",
"@babel-baseline/parser": "npm:@babel/parser@7.14.5",
"@babel/generator": "workspace:*",
"@babel/helper-validator-identifier": "workspace:*",
"@babel/parser": "workspace:*",
"benchmark": "^2.1.4"
}
}

View File

@ -75,7 +75,8 @@
"eslint/*",
"packages/*",
"test/esm",
"test/runtime-integration/*"
"test/runtime-integration/*",
"benchmark"
],
"resolutions": {
"browserslist": "npm:4.16.6",

View File

@ -24,12 +24,10 @@
"source-map": "^0.5.0"
},
"devDependencies": {
"@babel-baseline/generator": "npm:@babel/generator@7.14.5",
"@babel/helper-fixtures": "workspace:*",
"@babel/parser": "workspace:*",
"@types/jsesc": "^2.5.0",
"@types/source-map": "^0.5.0",
"benchmark": "^2.1.4",
"charcodes": "^0.2.0"
},
"engines": {

View File

@ -1,4 +1,3 @@
benchmark
src
test
*.log

View File

@ -1,17 +0,0 @@
export function report(event) {
const bench = event.target;
const timeMs = bench.stats.mean * 1000;
const time =
timeMs < 10
? `${Math.round(timeMs * 1000) / 1000}ms`
: `${Math.round(timeMs)}ms`;
const msg = `${bench.name}: ${formatNumber(bench.hz)} ops/sec ±${
Math.round(bench.stats.rme * 100) / 100
}% (${time})`;
console.log(msg);
}
function formatNumber(x) {
if (x < 100) return `${Math.round(x * 100) / 100}`;
return `${Math.round(x)}`.replace(/\d(?=(?:\d{3})+$)/g, "$&_");
}

View File

@ -14,9 +14,7 @@
"main": "./lib/index.js",
"exports": "./lib/index.js",
"devDependencies": {
"@babel/helper-validator-identifier-baseline": "npm:@babel/helper-validator-identifier@7.10.4",
"@unicode/unicode-13.0.0": "^1.0.6",
"benchmark": "^2.1.4",
"charcodes": "^0.2.0"
},
"engines": {

View File

@ -1,17 +0,0 @@
export function report(event) {
const bench = event.target;
const timeMs = bench.stats.mean * 1000;
const time =
timeMs < 10
? `${Math.round(timeMs * 1000) / 1000}ms`
: `${Math.round(timeMs)}ms`;
const msg = `${bench.name}: ${formatNumber(bench.hz)} ops/sec ±${
Math.round(bench.stats.rme * 100) / 100
}% (${time})`;
console.log(msg);
}
function formatNumber(x) {
if (x < 100) return `${Math.round(x * 100) / 100}`;
return `${Math.round(x)}`.replace(/\d(?=(?:\d{3})+$)/g, "$&_");
}

View File

@ -33,11 +33,9 @@
"node": ">=6.0.0"
},
"devDependencies": {
"@babel-baseline/parser": "npm:@babel/parser@^7.14.5",
"@babel/code-frame": "workspace:*",
"@babel/helper-fixtures": "workspace:*",
"@babel/helper-validator-identifier": "workspace:*",
"benchmark": "^2.1.4",
"charcodes": "^0.2.0"
},
"bin": "./bin/babel-parser.js"

View File

@ -16,7 +16,14 @@ __metadata:
languageName: node
linkType: hard
"@babel-baseline/parser@npm:@babel/parser@^7.14.5":
"@babel-baseline/helper-validator-identifier@npm:@babel/helper-validator-identifier@7.10.4":
version: 7.10.4
resolution: "@babel/helper-validator-identifier@npm:7.10.4"
checksum: 25098ef842e3ffecdd9a7216f6173da7ad7be1b0b3e454a9f6965055154b9ad7a4acd2f218ba3d2efc0821bdab97837b3cb815844af7d72f66f89d446a54efc6
languageName: node
linkType: hard
"@babel-baseline/parser@npm:@babel/parser@7.14.5":
version: 7.14.5
resolution: "@babel/parser@npm:7.14.5"
bin:
@ -74,6 +81,20 @@ __metadata:
languageName: unknown
linkType: soft
"@babel/benchmark@workspace:benchmark":
version: 0.0.0-use.local
resolution: "@babel/benchmark@workspace:benchmark"
dependencies:
"@babel-baseline/generator": "npm:@babel/generator@7.14.5"
"@babel-baseline/helper-validator-identifier": "npm:@babel/helper-validator-identifier@7.10.4"
"@babel-baseline/parser": "npm:@babel/parser@7.14.5"
"@babel/generator": "workspace:*"
"@babel/helper-validator-identifier": "workspace:*"
"@babel/parser": "workspace:*"
benchmark: ^2.1.4
languageName: unknown
linkType: soft
"@babel/cli@npm:^7.14.5":
version: 7.14.5
resolution: "@babel/cli@npm:7.14.5"
@ -346,13 +367,11 @@ __metadata:
version: 0.0.0-use.local
resolution: "@babel/generator@workspace:packages/babel-generator"
dependencies:
"@babel-baseline/generator": "npm:@babel/generator@7.14.5"
"@babel/helper-fixtures": "workspace:*"
"@babel/parser": "workspace:*"
"@babel/types": "workspace:^7.14.8"
"@types/jsesc": ^2.5.0
"@types/source-map": ^0.5.0
benchmark: ^2.1.4
charcodes: ^0.2.0
jsesc: "condition: BABEL_8_BREAKING ? ^3.0.2 : ^2.5.1"
source-map: ^0.5.0
@ -833,13 +852,6 @@ __metadata:
languageName: unknown
linkType: soft
"@babel/helper-validator-identifier-baseline@npm:@babel/helper-validator-identifier@7.10.4":
version: 7.10.4
resolution: "@babel/helper-validator-identifier@npm:7.10.4"
checksum: 25098ef842e3ffecdd9a7216f6173da7ad7be1b0b3e454a9f6965055154b9ad7a4acd2f218ba3d2efc0821bdab97837b3cb815844af7d72f66f89d446a54efc6
languageName: node
linkType: hard
"@babel/helper-validator-identifier@npm:^7.14.5":
version: 7.14.5
resolution: "@babel/helper-validator-identifier@npm:7.14.5"
@ -851,9 +863,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@babel/helper-validator-identifier@workspace:packages/babel-helper-validator-identifier"
dependencies:
"@babel/helper-validator-identifier-baseline": "npm:@babel/helper-validator-identifier@7.10.4"
"@unicode/unicode-13.0.0": ^1.0.6
benchmark: ^2.1.4
charcodes: ^0.2.0
languageName: unknown
linkType: soft
@ -975,11 +985,9 @@ __metadata:
version: 0.0.0-use.local
resolution: "@babel/parser@workspace:packages/babel-parser"
dependencies:
"@babel-baseline/parser": "npm:@babel/parser@^7.14.5"
"@babel/code-frame": "workspace:*"
"@babel/helper-fixtures": "workspace:*"
"@babel/helper-validator-identifier": "workspace:*"
benchmark: ^2.1.4
charcodes: ^0.2.0
bin:
parser: ./bin/babel-parser.js