docs(bench): disclose charset + secure-cost scope; add typecheck:bench script

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-07-06 23:17:58 -05:00
1 parent daa13f6f78
commit 7593d1425a
4 files changed
+128 -113

No files matched your search

+31 -24
View File
@@ -5,7 +5,7 @@
## Environment ## Environment
- **Date**: 2026-07-07 - **Date**: 2026-07-07
- **Commit**: 926ca39 - **Commit**: daa13f6
- **Node**: v22.22.2 - **Node**: v22.22.2
- **OS**: darwin - **OS**: darwin
- **CPU**: Apple M4 Max (16 cores) - **CPU**: Apple M4 Max (16 cores)
@@ -29,56 +29,60 @@
| Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s | | Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s |
| --- | --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- | --- |
| raw-http | 115,398 | 0.00 | 1.00 | 1.00 | 0.4% | 115,078–116,077 | | raw-http | 116,166 | 0.00 | 1.00 | 1.00 | 0.6% | 115,590–117,242 |
| green-tea | 98,912 | 0.00 | 1.00 | 2.00 | 0.5% | 98,835–99,962 | | green-tea | 97,760 | 0.00 | 1.00 | 2.00 | 0.3% | 97,094–97,837 |
| fastify | 85,882 | 1.00 | 2.00 | 2.00 | 0.3% | 85,382–86,074 | | fastify | 86,470 | 1.00 | 2.00 | 2.00 | 0.3% | 86,202–86,829 |
| express | 24,126 | 3.00 | 5.00 | 8.00 | 0.1% | 24,072–24,158 | | express | 24,005 | 3.00 | 6.00 | 9.00 | 0.3% | 23,989–24,136 |
### Route param ### Route param
| Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s | | Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s |
| --- | --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- | --- |
| raw-http | 115,437 | 0.00 | 1.00 | 1.00 | 0.3% | 115,245–116,013 | | raw-http | 117,024 | 0.00 | 1.00 | 1.00 | 0.3% | 116,538–117,242 |
| green-tea | 93,114 | 1.00 | 2.00 | 2.00 | 0.1% | 92,947–93,126 | | green-tea | 92,384 | 1.00 | 2.00 | 2.00 | 0.5% | 91,795–92,998 |
| fastify | 85,805 | 1.00 | 2.00 | 2.00 | 0.2% | 85,498–85,856 | | fastify | 85,754 | 1.00 | 2.00 | 2.00 | 0.3% | 85,651–86,317 |
| express | 23,739 | 4.00 | 5.00 | 8.00 | 0.1% | 23,694–23,778 | | express | 23,666 | 4.00 | 5.00 | 8.00 | 0.1% | 23,666–23,720 |
### Pipeline (3 steps) (approximation) ### Pipeline (3 steps) (approximation)
| Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s | | Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s |
| --- | --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- | --- |
| raw-http | 114,016 | 0.00 | 1.00 | 1.00 | 0.1% | 114,003–114,157 | | raw-http | 114,157 | 0.00 | 1.00 | 1.00 | 0.2% | 113,862–114,554 |
| green-tea | 84,230 | 1.00 | 2.00 | 2.00 | 0.5% | 84,179–85,050 | | fastify | 84,320 | 1.00 | 2.00 | 2.00 | 0.1% | 84,269–84,422 |
| fastify | 83,808 | 1.00 | 2.00 | 2.00 | 0.1% | 83,770–83,898 | | green-tea | 83,962 | 1.00 | 2.00 | 2.00 | 0.4% | 83,590–84,358 |
| express | 23,758 | 4.00 | 5.00 | 8.00 | 0.1% | 23,720–23,778 | | express | 23,829 | 4.00 | 5.00 | 8.00 | 0.1% | 23,768–23,851 |
### POST JSON + validation ### POST JSON + validation
| Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s | | Framework | req/s (median) | p50 (ms) | p99 (ms) | p999 (ms) | CV | min–max req/s |
| --- | --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- | --- |
| raw-http | 99,014 | 0.00 | 1.00 | 2.00 | 0.3% | 98,438–99,181 | | raw-http | 100,230 | 0.00 | 1.00 | 2.00 | 0.1% | 100,064–100,294 |
| green-tea | 76,486 | 1.00 | 2.00 | 2.00 | 0.2% | 76,397–76,691 | | green-tea | 76,243 | 1.00 | 2.00 | 2.00 | 0.2% | 76,192–76,550 |
| fastify | 63,869 | 1.00 | 2.00 | 3.00 | 0.3% | 63,837–64,323 | | fastify | 63,222 | 1.00 | 2.00 | 3.00 | 0.7% | 62,307–63,229 |
| express | 19,986 | 4.00 | 7.00 | 26.00 | 0.4% | 19,886–20,069 | | express | 19,870 | 4.00 | 7.00 | 23.00 | 0.3% | 19,758–19,883 |
## Step-scaling (green-tea) ## Step-scaling (green-tea)
| Path | Steps | req/s | | Path | Steps | req/s |
| --- | --- | --- | | --- | --- | --- |
| /steps/0 | 0 | 92,858 | | /steps/0 | 0 | 91,386 |
| /steps/3 | 3 | 81,658 | | /steps/3 | 3 | 81,530 |
| /steps/5 | 5 | 71,968 | | /steps/5 | 5 | 72,237 |
Each additional pipeline step costs roughly 4,178 req/s (-22.5% over 5 steps), on this box. Each additional pipeline step costs roughly 3,830 req/s (-21.0% over 5 steps), on this box.
## Cost of secure-by-default (green-tea) ## Cost of secure-by-default (green-tea)
| Label | req/s | | Label | req/s |
| --- | --- | | --- | --- |
| security:false (parity) | 98,912 | | security:false (parity) | 97,760 |
| security:true (default) | 93,178 | | security:true (default) | 93,306 |
The real cost of running secure-by-default (rather than the parity-mode `security:false` used above) is ~5.8% req/s on this box. The real cost of running secure-by-default (rather than the parity-mode `security:false` used above) is ~4.6% req/s on this box.
> Scope: this micro-bench currently measures the security-**headers** cost only (`security:false` vs
> `security:true` on `/hello`). The incremental cost of `@body` validation and CORS is not separately
> measured yet (deferred) — so this table is narrower than the design spec's 4-point plan.
## Methodology ## Methodology
@@ -95,3 +99,6 @@ The real cost of running secure-by-default (rather than the parity-mode `securit
`JSON.stringify` in these benchmarks. Fastify's `fast-json-stringify` response serializer is `JSON.stringify` in these benchmarks. Fastify's `fast-json-stringify` response serializer is
deliberately **not** engaged — only its input `schema.body` validation is used — so no framework deliberately **not** engaged — only its input `schema.body` validation is used — so no framework
gets a serialization fast path the others lack. gets a serialization fast path the others lack.
- **Content-type charset asymmetry (disclosed, not controlled)**: green-tea and raw-http send
`Content-Type: application/json` while Express and Fastify send `application/json; charset=utf-8`.
This is a minor header-byte asymmetry that is disclosed here rather than normalized away.
+7
View File
@@ -147,6 +147,10 @@ function renderSecureCost(secureCost: RenderData['secureCost']): string {
'', '',
deltaNote, deltaNote,
'', '',
'> Scope: this micro-bench currently measures the security-**headers** cost only (`security:false` vs',
'> `security:true` on `/hello`). The incremental cost of `@body` validation and CORS is not separately',
'> measured yet (deferred) — so this table is narrower than the design spec\'s 4-point plan.',
'',
].join('\n'); ].join('\n');
} }
@@ -167,6 +171,9 @@ function renderMethodology(): string {
' `JSON.stringify` in these benchmarks. Fastify\'s `fast-json-stringify` response serializer is', ' `JSON.stringify` in these benchmarks. Fastify\'s `fast-json-stringify` response serializer is',
' deliberately **not** engaged — only its input `schema.body` validation is used — so no framework', ' deliberately **not** engaged — only its input `schema.body` validation is used — so no framework',
' gets a serialization fast path the others lack.', ' gets a serialization fast path the others lack.',
'- **Content-type charset asymmetry (disclosed, not controlled)**: green-tea and raw-http send',
' `Content-Type: application/json` while Express and Fastify send `application/json; charset=utf-8`.',
' This is a minor header-byte asymmetry that is disclosed here rather than normalized away.',
'', '',
].join('\n'); ].join('\n');
} }
+89 -89
View File
@@ -1,7 +1,7 @@
{ {
"env": { "env": {
"date": "2026-07-07", "date": "2026-07-07",
"commit": "926ca39", "commit": "daa13f6",
"node": "v22.22.2", "node": "v22.22.2",
"os": "darwin", "os": "darwin",
"cpu": "Apple M4 Max (16 cores)", "cpu": "Apple M4 Max (16 cores)",
@@ -23,11 +23,11 @@
{ {
"framework": "raw-http", "framework": "raw-http",
"reqSec": { "reqSec": {
"median": 115398.4, "median": 116166.4,
"min": 115078.4, "min": 115590.4,
"max": 116076.8, "max": 117241.6,
"stddev": 416.2570146222469, "stddev": 684.2913999167365,
"cv": 0.003603399427582749 "cv": 0.005882187997853885
}, },
"p50": 0, "p50": 0,
"p99": 1, "p99": 1,
@@ -36,11 +36,11 @@
{ {
"framework": "fastify", "framework": "fastify",
"reqSec": { "reqSec": {
"median": 85881.6, "median": 86470.4,
"min": 85382.4, "min": 86201.6,
"max": 86073.6, "max": 86828.8,
"stddev": 291.32305092457597, "stddev": 256.92278130900564,
"cv": 0.0033961968743538755 "cv": 0.0029701964075911015
}, },
"p50": 1, "p50": 1,
"p99": 2, "p99": 2,
@@ -49,24 +49,24 @@
{ {
"framework": "express", "framework": "express",
"reqSec": { "reqSec": {
"median": 24126.4, "median": 24004.8,
"min": 24072, "min": 23988.8,
"max": 24158.4, "max": 24136,
"stddev": 35.66560746090835, "stddev": 65.9438144685816,
"cv": 0.0014787390042501193 "cv": 0.002742722036525155
}, },
"p50": 3, "p50": 3,
"p99": 5, "p99": 6,
"p999": 8 "p999": 9
}, },
{ {
"framework": "green-tea", "framework": "green-tea",
"reqSec": { "reqSec": {
"median": 98912, "median": 97760,
"min": 98835.2, "min": 97094.4,
"max": 99961.6, "max": 97836.8,
"stddev": 513.8455626180164, "stddev": 333.34655973759686,
"cv": 0.005178001751557391 "cv": 0.003416705658430423
}, },
"p50": 0, "p50": 0,
"p99": 1, "p99": 1,
@@ -81,11 +81,11 @@
{ {
"framework": "raw-http", "framework": "raw-http",
"reqSec": { "reqSec": {
"median": 115436.8, "median": 117024,
"min": 115244.8, "min": 116537.6,
"max": 116012.8, "max": 117241.6,
"stddev": 326.3372488699382, "stddev": 294.3072317607338,
"cv": 0.0028238464382747876 "cv": 0.0025168575864821115
}, },
"p50": 0, "p50": 0,
"p99": 1, "p99": 1,
@@ -94,11 +94,11 @@
{ {
"framework": "fastify", "framework": "fastify",
"reqSec": { "reqSec": {
"median": 85804.8, "median": 85753.6,
"min": 85497.6, "min": 85651.2,
"max": 85856, "max": 86316.8,
"stddev": 158.26975565645782, "stddev": 292.6323746044982,
"cv": 0.0018463688799174882 "cv": 0.0034063777495308683
}, },
"p50": 1, "p50": 1,
"p99": 2, "p99": 2,
@@ -107,11 +107,11 @@
{ {
"framework": "express", "framework": "express",
"reqSec": { "reqSec": {
"median": 23739.2, "median": 23665.6,
"min": 23694.4, "min": 23665.6,
"max": 23777.6, "max": 23720,
"stddev": 33.99973856108518, "stddev": 25.64440593103281,
"cv": 0.001432347940819078 "cv": 0.0010827856221020677
}, },
"p50": 4, "p50": 4,
"p99": 5, "p99": 5,
@@ -120,11 +120,11 @@
{ {
"framework": "green-tea", "framework": "green-tea",
"reqSec": { "reqSec": {
"median": 93113.6, "median": 92384,
"min": 92947.2, "min": 91795.2,
"max": 93126.4, "max": 92998.4,
"stddev": 81.62613960409276, "stddev": 491.24140252584004,
"cv": 0.000877111912051406 "cv": 0.005316895043385614
}, },
"p50": 1, "p50": 1,
"p99": 2, "p99": 2,
@@ -140,11 +140,11 @@
{ {
"framework": "raw-http", "framework": "raw-http",
"reqSec": { "reqSec": {
"median": 114016, "median": 114156.8,
"min": 114003.2, "min": 113862.4,
"max": 114156.8, "max": 114553.6,
"stddev": 69.58722743594919, "stddev": 283.21155029804993,
"cv": 0.0006101003060058202 "cv": 0.0024801579427618002
}, },
"p50": 0, "p50": 0,
"p99": 1, "p99": 1,
@@ -153,11 +153,11 @@
{ {
"framework": "fastify", "framework": "fastify",
"reqSec": { "reqSec": {
"median": 83808, "median": 84320,
"min": 83769.61, "min": 84268.8,
"max": 83897.6, "max": 84422.4,
"stddev": 53.62772106538676, "stddev": 63.857619400938304,
"cv": 0.0006397575458676833 "cv": 0.0007571714540811431
}, },
"p50": 1, "p50": 1,
"p99": 2, "p99": 2,
@@ -166,11 +166,11 @@
{ {
"framework": "express", "framework": "express",
"reqSec": { "reqSec": {
"median": 23758.4, "median": 23828.8,
"min": 23720, "min": 23768,
"max": 23777.6, "max": 23851.2,
"stddev": 23.946607275352836, "stddev": 35.151481713672865,
"cv": 0.001008193300579018 "cv": 0.001475960770644645
}, },
"p50": 4, "p50": 4,
"p99": 5, "p99": 5,
@@ -179,11 +179,11 @@
{ {
"framework": "green-tea", "framework": "green-tea",
"reqSec": { "reqSec": {
"median": 84230.4, "median": 83961.6,
"min": 84179.2, "min": 83590.4,
"max": 85049.6, "max": 84358.4,
"stddev": 398.7907053413738, "stddev": 313.5927436802211,
"cv": 0.004720176328277377 "cv": 0.0037345747973909107
}, },
"p50": 1, "p50": 1,
"p99": 2, "p99": 2,
@@ -198,11 +198,11 @@
{ {
"framework": "raw-http", "framework": "raw-http",
"reqSec": { "reqSec": {
"median": 99014.4, "median": 100230.4,
"min": 98438.4, "min": 100064,
"max": 99180.8, "max": 100294.4,
"stddev": 318.0885131881125, "stddev": 97.10768364152092,
"cv": 0.0032169839814651393 "cv": 0.0009691746695970135
}, },
"p50": 0, "p50": 0,
"p99": 1, "p99": 1,
@@ -211,11 +211,11 @@
{ {
"framework": "fastify", "framework": "fastify",
"reqSec": { "reqSec": {
"median": 63868.8, "median": 63222.4,
"min": 63836.8, "min": 62307.2,
"max": 64323.2, "max": 63228.8,
"stddev": 222.1331732692473, "stddev": 432.9457959401203,
"cv": 0.0034703102857891206 "cv": 0.006880951458691962
}, },
"p50": 1, "p50": 1,
"p99": 2, "p99": 2,
@@ -224,24 +224,24 @@
{ {
"framework": "express", "framework": "express",
"reqSec": { "reqSec": {
"median": 19985.6, "median": 19870.41,
"min": 19886.41, "min": 19758.41,
"max": 20068.8, "max": 19883.2,
"stddev": 74.55572725597027, "stddev": 56.05565508195131,
"cv": 0.003731467455443308 "cv": 0.0028257646983895677
}, },
"p50": 4, "p50": 4,
"p99": 7, "p99": 7,
"p999": 26 "p999": 23
}, },
{ {
"framework": "green-tea", "framework": "green-tea",
"reqSec": { "reqSec": {
"median": 76486.4, "median": 76243.2,
"min": 76396.8, "min": 76192,
"max": 76691.2, "max": 76550.4,
"stddev": 123.21731480058412, "stddev": 158.26975565645782,
"cv": 0.0016101618664875192 "cv": 0.0020735333006502306
}, },
"p50": 1, "p50": 1,
"p99": 2, "p99": 2,
@@ -254,27 +254,27 @@
{ {
"path": "/steps/0", "path": "/steps/0",
"steps": 0, "steps": 0,
"reqSec": 92857.6 "reqSec": 91385.6
}, },
{ {
"path": "/steps/3", "path": "/steps/3",
"steps": 3, "steps": 3,
"reqSec": 81657.61 "reqSec": 81529.61
}, },
{ {
"path": "/steps/5", "path": "/steps/5",
"steps": 5, "steps": 5,
"reqSec": 71968 "reqSec": 72236.8
} }
], ],
"secureCost": [ "secureCost": [
{ {
"label": "security:false (parity)", "label": "security:false (parity)",
"reqSec": 98912 "reqSec": 97760
}, },
{ {
"label": "security:true (default)", "label": "security:true (default)",
"reqSec": 93177.6 "reqSec": 93305.6
} }
] ]
} }
+1
View File
@@ -11,6 +11,7 @@
"test": "vitest run", "test": "vitest run",
"test:dev": "vitest", "test:dev": "vitest",
"typecheck": "tsc --noEmit -p tsconfig.json", "typecheck": "tsc --noEmit -p tsconfig.json",
"typecheck:bench": "tsc --noEmit -p bench/tsconfig.json",
"bench": "tsx bench/run.ts" "bench": "tsx bench/run.ts"
}, },
"dependencies": { "dependencies": {