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