Files
core/bench/servers/scale-express.ts
chrnx 3a4cd5a7ce
CI / build (pull_request) Successful in 59s
test(bench): reach bench servers cross-host + add scale and Bun/Deno servers
Fastify and the Nest adapters bound 127.0.0.1, unreachable from a separate load generator; bind 0.0.0.0 so two-machine benchmarks work.

Adds scale-{green-tea,express} (step-vs-middleware depth sweeps that surfaced the O(n^2)) and green-tea-{bun,deno} (the same app served via serveBun/serveDeno, to benchmark across runtimes).

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
2026-07-17 19:05:52 -05:00

27 lines
763 B
TypeScript

import express from 'express';
// Express counterpart: /chain/N runs N trivial middlewares before the handler —
// the closest apples-to-apples to green-tea's N chained steps.
const app = express();
app.disable('x-powered-by');
app.set('etag', false);
const mw = (_req: any, _res: any, next: any) => next();
function route(path: string, n: number): void {
const chain = Array.from({ length: n }, () => mw);
app.get(path, ...chain, (_req, res) => { res.json({ ok: 1 }); });
}
route('/chain/0', 0);
route('/chain/10', 10);
route('/chain/25', 25);
route('/chain/50', 50);
route('/chain/75', 75);
route('/chain/100', 100);
const server = app.listen(0, () => {
server.keepAliveTimeout = 5000;
console.log(`READY ${(server.address() as any).port}`);
});