Benchmarking
Performance
The kernel ships with two benchmark suites. Each framework does the same work in both: a chain of pass-through middleware followed by one that responds with OK, or a single middleware that responds with a JSON payload.
- In-process hands each framework a web
Requestdirectly, with no network, using Mitata. It compares Raptor with Hono, H3 and Elysia. - HTTP runs each framework on its own server in a separate process and loads it with autocannon. On Node it compares Raptor, with and without lightweight mode, with Hono, H3, Express, Koa and Fastify. On Deno it compares Raptor with Hono, H3 and Elysia.
Elysia and Fastify have no next() style middleware, so each step in their chain is an onRequest hook instead. Elysia compiles its hooks, so a long chain costs it very little.
Results
Requests per second over HTTP on Node 26.13, on an Apple M1. Higher is better.
| Scenario | Raptor | Raptor (lightweight) | Hono | H3 | Express | Koa | Fastify |
|---|---|---|---|---|---|---|---|
| Single middleware | 69,907 | 114,694 | 112,749 | 110,778 | 60,541 | 105,440 | 124,870 |
| 10 middleware | 60,726 | 100,243 | 94,854 | 86,726 | 54,659 | 91,795 | 120,826 |
| 50 middleware | 47,786 | 64,054 | 51,370 | 54,461 | 42,794 | 61,597 | 86,256 |
| 100 middleware | 36,931 | 47,683 | 36,662 | 37,949 | 42,518 | 49,642 | 82,810 |
| 200 middleware | 26,802 | 30,901 | 23,438 | 25,256 | 28,440 | 34,691 | 57,891 |
| JSON response | 49,872 | 67,296 | 69,011 | 63,965 | 41,712 | 59,402 | 76,704 |
Fastify leads every scenario, because it works on Node's own request and response objects rather than the web standard ones. Koa pulls ahead on the longest chains, because it handles an error once at the top, where Raptor handles it at the middleware that raised it.
Running Benchmarks
Fork @raptor-js/kernel, then run any of the suites. Close other busy programs first, since anything else using the CPU skews the results.
npm install
npm run bench # in-process
npm run bench:http # over HTTP, on Node
npm run bench:http:deno # over HTTP, on Deno