|
1 | | -import { run, bench, group } 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" |
4 | 4 |
|
5 | 5 | function setupRouter(router) { |
6 | 6 | router.use((req, next) => { |
7 | | - return next(); |
8 | | - }); |
| 7 | + return next() |
| 8 | + }) |
9 | 9 |
|
10 | 10 | router.get("/", () => { |
11 | | - return new Response(); |
12 | | - }); |
| 11 | + return new Response() |
| 12 | + }) |
13 | 13 | router.get("/:id", async (req) => { |
14 | | - return new Response(req.params.id); |
15 | | - }); |
| 14 | + return new Response(req.params.id) |
| 15 | + }) |
16 | 16 | router.get("/:id/error", () => { |
17 | | - throw new Error("Error"); |
18 | | - }); |
| 17 | + throw new Error("Error") |
| 18 | + }) |
19 | 19 | } |
20 | 20 |
|
21 | | -const { router } = httpNext(); |
22 | | -setupRouter(router); |
| 21 | +const { router } = httpNext() |
| 22 | +setupRouter(router) |
23 | 23 |
|
24 | | -const { router: routerPrevious } = httpPrevious(); |
25 | | -setupRouter(routerPrevious); |
| 24 | +const { router: routerPrevious } = httpPrevious() |
| 25 | +setupRouter(routerPrevious) |
26 | 26 |
|
27 | 27 | group("Next Router", () => { |
28 | 28 | bench("Parameter URL", () => { |
29 | | - router.fetch(new Request(new URL("http://localhost/0"))); |
30 | | - }); |
| 29 | + router.fetch(new Request(new URL("http://localhost/0"))) |
| 30 | + }).gc("inner") |
31 | 31 | bench("Not Found URL", () => { |
32 | | - router.fetch(new Request(new URL("http://localhost/0/404"))); |
33 | | - }); |
| 32 | + router.fetch(new Request(new URL("http://localhost/0/404"))) |
| 33 | + }).gc("inner") |
34 | 34 | bench("Error URL", () => { |
35 | | - router.fetch(new Request(new URL("http://localhost/0/error"))); |
36 | | - }); |
37 | | -}); |
| 35 | + router.fetch(new Request(new URL("http://localhost/0/error"))) |
| 36 | + }).gc("inner") |
| 37 | +}) |
38 | 38 |
|
39 | 39 | group("Previous Router", () => { |
40 | 40 | bench("Parameter URL", () => { |
41 | | - routerPrevious.fetch(new Request(new URL("http://localhost/0"))); |
42 | | - }); |
| 41 | + routerPrevious.fetch(new Request(new URL("http://localhost/0"))) |
| 42 | + }).gc("inner") |
43 | 43 | bench("Not Found URL", () => { |
44 | | - routerPrevious.fetch(new Request(new URL("http://localhost/0/404"))); |
45 | | - }); |
| 44 | + routerPrevious.fetch(new Request(new URL("http://localhost/0/404"))) |
| 45 | + }).gc("inner") |
46 | 46 | bench("Error URL", () => { |
47 | | - routerPrevious.fetch(new Request(new URL("http://localhost/0/error"))); |
48 | | - }); |
49 | | -}); |
| 47 | + routerPrevious.fetch(new Request(new URL("http://localhost/0/error"))) |
| 48 | + }).gc("inner") |
| 49 | +}) |
50 | 50 |
|
51 | 51 | await run({ |
52 | 52 | colors: true, |
53 | | -}); |
| 53 | +}) |
0 commit comments