Skip to content

Commit

Permalink
chore: update benchmark (#3102)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe authored Jul 6, 2024
1 parent cff2768 commit bee3ade
Show file tree
Hide file tree
Showing 6 changed files with 2,098 additions and 827 deletions.
13 changes: 7 additions & 6 deletions benchmarks/routers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
},
"dependencies": {
"@medley/router": "^0.2.1",
"express": "^4.18.2",
"find-my-way": "^7.4.0",
"koa-router": "^12.0.0",
"express": "^4.19.2",
"find-my-way": "^8.2.0",
"koa-router": "^12.0.1",
"koa-tree-router": "^0.12.1",
"memoirist": "^0.1.4",
"memoirist": "^0.2.0",
"mitata": "^0.1.6",
"radix3": "^1.0.1",
"radix3": "^1.1.2",
"rou3": "^0.1.0",
"trek-router": "^1.2.0"
}
}
}
5 changes: 4 additions & 1 deletion benchmarks/routers/src/bench.mts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { run, bench, group } from 'mitata'
import { expressRouter } from './express.mts'
import { findMyWayRouter } from './find-my-way.mts'
import { regExpRouter, trieRouter } from './hono.mts'
import { regExpRouter, trieRouter, patternRouter } from './hono.mts'
import { koaRouter } from './koa-router.mts'
import { koaTreeRouter } from './koa-tree-router.mts'
import { medleyRouter } from './medley-router.mts'
import { memoiristRouter } from './memoirist.mts'
import { radix3Router } from './radix3.mts'
import type { Route, RouterInterface } from './tool.mts'
import { trekRouter } from './trek-router.mts'
import { rou3Router } from './rou3.mts'

const routers: RouterInterface[] = [
regExpRouter,
trieRouter,
patternRouter,
medleyRouter,
findMyWayRouter,
koaTreeRouter,
Expand All @@ -21,6 +23,7 @@ const routers: RouterInterface[] = [
koaRouter,
radix3Router,
memoiristRouter,
rou3Router,
]

medleyRouter.match({ method: 'GET', path: '/user' })
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/routers/src/hono.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { RegExpRouter } from '../../../src/router/reg-exp-router/index.ts'
import { TrieRouter } from '../../../src/router/trie-router/index.ts'
import { PatternRouter } from '../../../src/router/pattern-router/index.ts'
import type { Router } from '../../../src/router.ts'
import type { RouterInterface } from './tool.mts'
import { routes, handler } from './tool.mts'
Expand All @@ -18,3 +19,4 @@ const createHonoRouter = (name: string, router: Router<unknown>): RouterInterfac

export const regExpRouter = createHonoRouter('RegExpRouter', new RegExpRouter())
export const trieRouter = createHonoRouter('TrieRouter', new TrieRouter())
export const patternRouter = createHonoRouter('PatternRouter', new PatternRouter())
19 changes: 19 additions & 0 deletions benchmarks/routers/src/rou3.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { addRoute, createRouter, findRoute } from 'rou3'
import type { RouterInterface } from './tool.mts'
import { handler, routes } from './tool.mts'

const name = 'rou3'
const router = createRouter()

for (const route of routes) {
addRoute(router, route.path, route.method, handler)
}

export const rou3Router: RouterInterface = {
name,
match: (route) => {
findRoute(router, route.path, route.method, {
ignoreParams: false, // Don't ignore params
})
},
}
5 changes: 4 additions & 1 deletion benchmarks/routers/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"allowImportingTsExtensions": true,
"esModuleInterop": true,
"module": "NodeNext"
}
},
"include": [
"./src"
]
}
Loading

0 comments on commit bee3ade

Please sign in to comment.