Skip to content

Commit 541e040

Browse files
committed
updating benchmark
1 parent 8c0d524 commit 541e040

File tree

3 files changed

+50
-58
lines changed

3 files changed

+50
-58
lines changed

bench.ts

Lines changed: 41 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,53 @@
1-
import { run, bench, group, baseline } from 'mitata';
2-
import httpNext from './index'
3-
import httpPrevious from '0http-bun'
1+
import { run, bench, group } from "mitata";
2+
import httpNext from "./index";
3+
import httpPrevious from "0http-bun";
44

55
function setupRouter(router) {
66
router.use((req, next) => {
7-
return next()
8-
})
7+
return next();
8+
});
99

10-
router.get('/', () => {
11-
return new Response()
12-
})
13-
router.get('/:id', async (req) => {
14-
return new Response(req.params.id)
15-
})
16-
router.get('/:id/error', () => {
17-
throw new Error('Error')
18-
})
10+
router.get("/", () => {
11+
return new Response();
12+
});
13+
router.get("/:id", async (req) => {
14+
return new Response(req.params.id);
15+
});
16+
router.get("/:id/error", () => {
17+
throw new Error("Error");
18+
});
1919
}
2020

21-
const { router } = httpNext()
22-
setupRouter(router)
21+
const { router } = httpNext();
22+
setupRouter(router);
2323

24-
const { router: routerPrevious } = httpPrevious()
25-
setupRouter(routerPrevious)
24+
const { router: routerPrevious } = httpPrevious();
25+
setupRouter(routerPrevious);
2626

27-
group('Next Router', () => {
28-
baseline('Base URL', () => {
29-
router.fetch(new Request(new URL('http://localhost/')))
30-
})
31-
bench('Parameter URL', () => {
32-
router.fetch(new Request(new URL('http://localhost/0')))
33-
})
34-
bench('Not Found URL', () => {
35-
router.fetch(new Request(new URL('http://localhost/0/404')))
36-
})
37-
bench('Error URL', () => {
38-
router.fetch(new Request(new URL('http://localhost/0/error')))
39-
})
40-
})
27+
group("Next Router", () => {
28+
bench("Parameter URL", () => {
29+
router.fetch(new Request(new URL("http://localhost/0")));
30+
});
31+
bench("Not Found URL", () => {
32+
router.fetch(new Request(new URL("http://localhost/0/404")));
33+
});
34+
bench("Error URL", () => {
35+
router.fetch(new Request(new URL("http://localhost/0/error")));
36+
});
37+
});
4138

42-
group('Previous Router', () => {
43-
baseline('Base URL', () => {
44-
routerPrevious.fetch(new Request(new URL('http://localhost/')))
45-
})
46-
bench('Parameter URL', () => {
47-
routerPrevious.fetch(new Request(new URL('http://localhost/0')))
48-
})
49-
bench('Not Found URL', () => {
50-
routerPrevious.fetch(new Request(new URL('http://localhost/0/404')))
51-
})
52-
bench('Error URL', () => {
53-
routerPrevious.fetch(new Request(new URL('http://localhost/0/error')))
54-
})
55-
})
39+
group("Previous Router", () => {
40+
bench("Parameter URL", () => {
41+
routerPrevious.fetch(new Request(new URL("http://localhost/0")));
42+
});
43+
bench("Not Found URL", () => {
44+
routerPrevious.fetch(new Request(new URL("http://localhost/0/404")));
45+
});
46+
bench("Error URL", () => {
47+
routerPrevious.fetch(new Request(new URL("http://localhost/0/error")));
48+
});
49+
});
5650

5751
await run({
58-
silent: false,
59-
avg: true,
60-
json: false,
6152
colors: true,
62-
min_max: false,
63-
percentiles: false
64-
})
53+
});

package-lock.json

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

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"lint": "bun x standard",
8-
"format": "bun x standard --fix"
8+
"format": "bun x standard --fix",
9+
"test": "bun test"
910
},
1011
"dependencies": {
1112
"fast-querystring": "^1.1.2",
@@ -26,7 +27,7 @@
2627
"devDependencies": {
2728
"0http-bun": "^1.0.3",
2829
"bun-types": "^1.1.8",
29-
"mitata": "^0.1.11"
30+
"mitata": "^1.0.32"
3031
},
3132
"keywords": [
3233
"http",

0 commit comments

Comments
 (0)