Skip to content

Commit 179c36d

Browse files
committed
feat: add babel benchmark
1 parent a1ba417 commit 179c36d

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ packages operations.
99
- [x] lodash
1010
- [x] prettier
1111
- [ ] webpack
12-
- [ ] babel
12+
- [x] babel
1313
- [ ] moment
1414
- [ ] dotenv
1515
- [ ] pinojs

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"dependencies": {
3+
"@babel/standalone": "7.24.0",
34
"fastify": "4.26.1",
45
"lodash": "4.17.21",
56
"piscina": "4.4.0",

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/babel-benchmark.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const fs = require('node:fs');
2+
const path = require('node:path');
3+
const Babel = require('@babel/standalone');
4+
5+
const payloads = [
6+
'lodash.fp.js',
7+
].map((file) => fs.readFileSync(path.join(__dirname, '..', 'fixtures', file), 'utf8'));
8+
9+
module.exports = {
10+
name: 'babel',
11+
type: 'operation',
12+
operations: [
13+
{
14+
name: 'transform (code=true ast=true)',
15+
fn: () => {
16+
let v = undefined;
17+
for (const p of payloads) {
18+
v = Babel.transform(p, { code: true, ast: true }).code;
19+
}
20+
return v;
21+
},
22+
},
23+
{
24+
name: 'transform (code=false)',
25+
fn: () => {
26+
let v = undefined;
27+
for (const p of payloads) {
28+
v = Babel.transform(p, { code: false }).code;
29+
}
30+
return v;
31+
},
32+
}
33+
],
34+
benchmarker: 'benchmarkjs',
35+
};

0 commit comments

Comments
 (0)