mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
* enable prefer-node-protocol rule * prefer node protocol import * fix broken scripts * fix e2e-old-babel error * strip node: protocol for old node versions * update Makefile.mjs
40 lines
860 B
JavaScript
40 lines
860 B
JavaScript
import { readFileSync } from "node:fs";
|
|
import {
|
|
currentCore,
|
|
baselineCore,
|
|
presetTypescript,
|
|
Benchmark,
|
|
} from "../../util.mjs";
|
|
import commonjs from "@babel/plugin-transform-modules-commonjs";
|
|
|
|
const benchmark = new Benchmark();
|
|
|
|
const input = readFileSync(
|
|
new URL("./babel-parser-tokenizer-index.txt", import.meta.url),
|
|
"utf-8"
|
|
);
|
|
function benchCases(name, implementation, options = {}) {
|
|
benchmark.add(
|
|
name,
|
|
() => {
|
|
implementation(input, {
|
|
presets: [presetTypescript],
|
|
plugins: [commonjs],
|
|
targets: "node 6",
|
|
configFile: false,
|
|
babelrc: false,
|
|
...options,
|
|
});
|
|
},
|
|
{
|
|
// increase minSamples for accuracy
|
|
minSamples: 100,
|
|
}
|
|
);
|
|
}
|
|
|
|
benchCases("baseline", baselineCore.transformSync);
|
|
benchCases("current", currentCore.transformSync);
|
|
|
|
benchmark.run();
|