Skip to content

Commit f19ce30

Browse files
committed
chore: add benchmark
1 parent dabd48e commit f19ce30

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

benchmark/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { createCors } from '../dist';
2+
3+
(async () => {
4+
const { summary, run, bench } = await import('mitata');
5+
6+
summary(() => {
7+
bench('base line', () => {
8+
const _req = new Request('https://example.com');
9+
const _resp = new Response();
10+
});
11+
12+
const cors = createCors();
13+
bench('createCors', () => {
14+
const req = new Request('https://example.com');
15+
const resp = new Response();
16+
return cors(req, resp);
17+
});
18+
});
19+
20+
return run();
21+
})();

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"test": "SWC_NODE_IGNORE_DYNAMIC=1 SWC_NODE_INLINE_SOURCE_MAP=1 mocha --require @swc-node/register --parallel --full-trace ./src/**/*.test.ts",
2525
"build": "rollup -c rollup.config.ts --configPlugin swc3 --bundleConfigAsCjs",
2626
"prerelease": "pnpm run lint && pnpm run test && pnpm run build",
27+
"bench": "SWC_NODE_IGNORE_DYNAMIC=1 node --require @swc-node/register ./benchmark/index.ts",
2728
"release": "bumpp -r --all --commit \"release: %s\" --tag \"%s\""
2829
},
2930
"keywords": [
@@ -48,6 +49,7 @@
4849
"eslint-config-sukka": "^8.1.0",
4950
"eslint-formatter-sukka": "^8.1.0",
5051
"expect": "^30.2.0",
52+
"mitata": "^1.0.34",
5153
"mocha": "^11.7.5",
5254
"rollup-plugin-dts": "^6.3.0",
5355
"typescript": "^5.9.3",

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.

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
"strictNullChecks": true,
1515
"skipLibCheck": true
1616
},
17-
"include": ["src/**/*.ts", "src/**/*.tsx"]
17+
"include": ["src/**/*.ts", "src/**/*.tsx", "benchmark/**/*.ts"]
1818
}

0 commit comments

Comments
 (0)