Skip to content

Commit

Permalink
perf: add suite for un-undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
pionxzh committed Nov 27, 2023
1 parent 59e2929 commit 3cd85f6
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 2 deletions.
2 changes: 2 additions & 0 deletions benches/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/*.json
/*.html
16 changes: 16 additions & 0 deletions benches/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@wakaru/benches",
"type": "module",
"version": "0.0.0",
"private": true,
"author": "Pionxzh",
"license": "MIT",
"main": "src/index.ts",
"scripts": {
"lint": "eslint src",
"lint:fix": "eslint src --fix"
},
"devDependencies": {
"benny": "^3.7.1"
}
}
41 changes: 41 additions & 0 deletions benches/un-undefined.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env npx tsx

import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { add, complete, cycle, save, suite } from 'benny'
import { runTransformations, transformationMap } from '../packages/unminify/src/index'

const __dirname = dirname(fileURLToPath(import.meta.url))

const title = 'un-undefined'
const rule = transformationMap[title]
const snippet = `
void 0;
void 99;
`

const main = async () => {
await suite(
title,
...([10, 100, 1000, 5000].map((count) => {
const source = snippet.repeat(count)
return add(`items=${count}`, () => {
runTransformations({ path: '', source }, [rule])
})
})),
cycle(),
complete(),
save({
file: title,
folder: __dirname,
format: 'json',
}),
save({
file: title,
folder: __dirname,
format: 'chart.html',
}),
)
}

main()
162 changes: 160 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
packages:
- 'benches'
- 'packages/*'
# exclude testcases
- '!testcases/*'

0 comments on commit 3cd85f6

Please sign in to comment.