bench(compare): add compression cases to the A/B harness
CI / dco (pull_request) Successful in 5s
CI / build (pull_request) Successful in 29s
CI / runtimes (bun) (pull_request) Successful in 19s
CI / runtimes (edge) (pull_request) Successful in 23s
CI / runtimes (deno) (pull_request) Successful in 32s

The A/B harness had no case with compression on, so a change to the
response write path was measured only on its uncompressed branch. Add an
8 KB JSON response uncompressed, identity-negotiated, gzip and br, plus a
small response under the threshold with compression enabled.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-10-26 13:23:55 -05:00
1 parent 8b67b1a46c
commit ad2b33584b
2 files changed
+16

No files matched your search

+7
View File
@@ -18,12 +18,17 @@ function makeStep(n: number) {
}
const steps = [1, 2, 3, 4, 5].map(makeStep);
// ~8 KB of JSON: well over the 1024-byte compression threshold, and repetitive the way list
// responses are, so the encoders do real work rather than bailing out on incompressible input.
const BIG = Array.from({ length: 120 }, (_, i) => ({ id: i, name: `user ${i}`, email: `user${i}@example.com`, active: i % 2 === 0 }));
@Route('/')
class Bench {
@Get('/hello') hello() { return { hello: 'world' }; }
@Get('/users/:id') user(@param('id') id: string) { return { id }; }
@Get('/pipeline') pipeline(@needs('s3') s3: number) { return { hello: 'world', s3 }; }
@Post('/validate') validate(@body(emailSchema) b: any) { return { email: b.email }; }
@Get('/big') big() { return BIG; }
@Get('/steps/5') steps5(@needs('s5') s5: number) { return { hello: 'world', s5 }; }
// Reads the counter without resetting it — the read itself carries no Origin, so it cannot
// change what it reports.
@@ -68,10 +73,12 @@ const cors =
}
: undefined;
// Only passed when asked for, so the file still boots against a revision without compression.
const app = createApp({
modules: [BenchModule],
security: process.env.GT_SECURE === '1',
...(cors ? { cors } : {}),
...(process.env.GT_COMPRESS === '1' ? { compression: true } : {}),
});
async function main() {