chore: update benchmark script (#120)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* chore: fix benchmark script * update readme
authored by Yusuke Wada · committed by GitHub · parent 7c454ee · Browse files · 2 files·+17 added−17 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+17 added−17 removed
- other:+17 added−17 removed
Provenance
- Commit
32686f4- Tree
0e8081c- Author
Yusuke Wada <yusuke@kamawada.com>- Committer
GitHub <noreply@github.com>- Parent
7c454ee
2 files changed+17 added−17 removed
modified:benchmarks/handle-event/index.js+12 added-12 removed
17 unmodified lines1819202122222425262728292324252627283529303132332 unmodified lines3637383946404142434445464742 unmodified lines909192939794959697989910010110210410310410510610710810916 unmodified lines12612712812912913013113213317 unmodified lines17 unmodified lines hono.get('/event/:id/comments', () => new Response('Event Comments')) hono.post('/event/:id/comments', () => new Response('POST Event Comments')) hono.post('/status', () => new Response('Status')) hono.get('/very/deeply/nested/route/hello/there', () => new Response('Very Deeply Nested Route')) //hono.get('/static/*', () => new Response('Static')) hono.get('/user/lookup/username/:username', (c) => { return new Response(`Hello ${c.req.param('username')}`, { status: 200, headers: { 'Content-Type': 'text/plain;charset=UTF-8', }, }) return c.text(`Hello ${c.req.param('username')}`) }) return hono}
const hono = initHono(new Hono())const honoWithRegExpRouter = initHono(new Hono({routerClass: RegExpRouter}))const honoWithRegExpRouter = initHono(new Hono({ routerClass: RegExpRouter }))
const ittyRouter = IttyRouter()ittyRouter.get('/user', () => new Response('User'))ittyRouter.get('/user/comments', () => new Response('User Comments'))2 unmodified linesittyRouter.get('/event/:id', () => new Response('Event'))ittyRouter.get('/event/:id/comments', () => new Response('Event Comments'))ittyRouter.post('/event/:id/comments', () => new Response('POST Event Comments'))ittyRouter.post('/status', () => new Response('Status'))ittyRouter.get('/very/deeply/nested/route/hello/there', () => new Response('Very Deeply Nested Route'))ittyRouter.get( '/very/deeply/nested/route/hello/there', () => new Response('Very Deeply Nested Route'))//ittyRouter.get('/static/*', () => new Response('Static'))ittyRouter.get('/user/lookup/username/:username', ({ params }) => { return new Response(`Hello ${params.username}`, { status: 200,42 unmodified linesconst worktopRouter = new WorktopRouter()worktopRouter.add('GET', '/', async (req, res) => res.send(200, 'User'))worktopRouter.add('GET', '/user/comments', (req, res) => res.send(200, 'User Comments'))worktopRouter.add('GET', '/user/avatar', (req, res) => res.send(200, 'User Avatar'))worktopRouter.add('GET', '/user/lookup/email/:address', (req, res) => res.send(200, 'User Lookup Email Address'))worktopRouter.add('GET', '/user/lookup/email/:address', (req, res) => res.send(200, 'User Lookup Email Address'))worktopRouter.add('GET', '/event/:id', (req, res) => res.send(200, 'Event'))worktopRouter.add('POST', '/event/:id/comments', (req, res) => res.send(200, 'POST Event Comments'))worktopRouter.add('POST', '/status', (req, res) => res.send(200, 'Status'))worktopRouter.add('GET', '/very/deeply/nested/route/hello/there', (req, res) => res.send(200, 'Very Deeply Nested Route'))worktopRouter.add('GET', '/user/lookup/username/:username', (req, res) => res.send(200, `Hello ${req.params.username}`))worktopRouter.add('GET', '/user/lookup/username/:username', (req, res) => res.send(200, `Hello ${req.params.username}`))
// Request Objectconst request = new Request('/user/lookup/username/hey', { method: 'GET' })// FetchEvent Object16 unmodified linesconst suite = new Benchmark.Suite()
suite .add('hono', async () => { // hono.matchRoute('GET', '/user/lookup/username/hey') await hono.handleEvent(event) }) .add('hono with RegExpRouter', async () => { await honoWithRegExpRouter.handleEvent(event)17 unmodified linesmodified:README.md+5 added-5 removed
29 unmodified lines30 31 **Hono is fastest** compared to other routers for Cloudflare Workers.32 33 ```plain34-hono x 779,197 ops/sec ±6.55% (78 runs sampled)35-itty-router x 161,813 ops/sec ±3.87% (87 runs sampled)36-sunder x 334,096 ops/sec ±1.33% (93 runs sampled)37-worktop x 212,661 ops/sec ±4.40% (81 runs sampled)34+hono x 809,503 ops/sec ±6.94% (73 runs sampled)35+itty-router x 157,310 ops/sec ±4.31% (87 runs sampled)36+sunder x 328,350 ops/sec ±2.30% (95 runs sampled)37+worktop x 209,758 ops/sec ±4.28% (83 runs sampled)38 Fastest is hono39-✨ Done in 58.29s.39+✨ Done in 60.66s.40 ```41 42 ## Hono in 1 minute43 452 unmodified lines