Skip to content

Commit 57f4ab5

Browse files
committed
test: add h3-compiled to bench
1 parent 4a6d71a commit 57f4ab5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/bench/bench.impl.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { compileRouter } from "rou3/compiler";
12
import * as _h3src from "../../src/index.ts";
23
import * as _h3v1 from "h3-v1";
34
import * as _h3nightly from "h3-nightly";
@@ -8,6 +9,7 @@ type AppFetch = (req: Request) => Response | Promise<Response>;
89
export function createInstances(): Array<[string, AppFetch]> {
910
return [
1011
["h3", h3(_h3src)],
12+
["h3-compiled", h3(_h3src, true)],
1113
["h3-nightly", h3(_h3nightly as any)],
1214
["h3-middleware", h3Middleware(_h3src)],
1315
// ["h3-v1", h3v1()],
@@ -16,7 +18,7 @@ export function createInstances(): Array<[string, AppFetch]> {
1618
] as const;
1719
}
1820

19-
export function h3(lib: typeof _h3src): AppFetch {
21+
export function h3(lib: typeof _h3src, compiled?: boolean): AppFetch {
2022
const app = new lib.H3()
2123
.get("/", () => "Hi")
2224
.get("/id/:id", (event) => {
@@ -25,6 +27,10 @@ export function h3(lib: typeof _h3src): AppFetch {
2527
return `${event.context.params!.id} ${name}`;
2628
})
2729
.post("/json", (event) => event.req.json());
30+
if (compiled) {
31+
const findRoute = compileRouter(app._rou3);
32+
app._findRoute = (event) => findRoute(event.req.method, event.url.pathname);
33+
}
2834
return app.fetch;
2935
}
3036

0 commit comments

Comments
 (0)