docs(bench): generate BENCHMARKS.md and link from README
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
3 files changed
+388
No files matched your search
@@ -0,0 +1,97 @@
|
||||
> **TL;DR**: `raw-http` posted the highest median req/s in the first benchmarked scenario on this box — see the single-box caveat below before reading anything into the absolute numbers.
|
||||
|
||||
# green-tea Benchmarks
|
||||
|
||||
## Environment
|
||||
|
||||
- **Date**: 2026-07-07
|
||||
- **Commit**: 926ca39
|
||||
- **Node**: v22.22.2
|
||||
- **OS**: darwin
|
||||
- **CPU**: Apple M4 Max (16 cores)
|
||||
- **RAM**: 69 GB
|
||||
- **Core-pinned**: no
|
||||
- **autocannon config**: 100 connections, 5s duration, 3 runs (1 warmup discarded), pipelining 1
|
||||
|
||||
> **A note on honesty: this is a single-box benchmark.** All frameworks were driven with autocannon over
|
||||
> loopback on the same machine, sharing the same cores as the server processes they measured. That
|
||||
> contention overstates absolute throughput for every framework and compresses the differences *between*
|
||||
> frameworks — do not read the raw req/s numbers as what you would see on separate client/server hardware.
|
||||
> The honest takeaway is the **ratio** between frameworks in the same table, not any single absolute
|
||||
> number. Note also that green-tea runs with `security:false` in the cross-framework tables below, purely
|
||||
> for response-header parity with the other frameworks (none of which set the same security headers by
|
||||
> default) — the real cost of running green-tea secure-by-default is measured separately in its own
|
||||
> section further down.
|
||||
|
||||
## Cross-framework scenarios
|
||||
|
||||
### JSON hello (overhead)
|
||||
|
||||
| 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 |
|
||||
| green-tea | 98,912 | 0.00 | 1.00 | 2.00 | 0.5% | 98,835–99,962 |
|
||||
| fastify | 85,882 | 1.00 | 2.00 | 2.00 | 0.3% | 85,382–86,074 |
|
||||
| express | 24,126 | 3.00 | 5.00 | 8.00 | 0.1% | 24,072–24,158 |
|
||||
|
||||
### Route param
|
||||
|
||||
| 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 |
|
||||
| green-tea | 93,114 | 1.00 | 2.00 | 2.00 | 0.1% | 92,947–93,126 |
|
||||
| fastify | 85,805 | 1.00 | 2.00 | 2.00 | 0.2% | 85,498–85,856 |
|
||||
| express | 23,739 | 4.00 | 5.00 | 8.00 | 0.1% | 23,694–23,778 |
|
||||
|
||||
### Pipeline (3 steps) (approximation)
|
||||
|
||||
| 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 |
|
||||
| green-tea | 84,230 | 1.00 | 2.00 | 2.00 | 0.5% | 84,179–85,050 |
|
||||
| fastify | 83,808 | 1.00 | 2.00 | 2.00 | 0.1% | 83,770–83,898 |
|
||||
| express | 23,758 | 4.00 | 5.00 | 8.00 | 0.1% | 23,720–23,778 |
|
||||
|
||||
### POST JSON + validation
|
||||
|
||||
| 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 |
|
||||
| green-tea | 76,486 | 1.00 | 2.00 | 2.00 | 0.2% | 76,397–76,691 |
|
||||
| fastify | 63,869 | 1.00 | 2.00 | 3.00 | 0.3% | 63,837–64,323 |
|
||||
| express | 19,986 | 4.00 | 7.00 | 26.00 | 0.4% | 19,886–20,069 |
|
||||
|
||||
## Step-scaling (green-tea)
|
||||
|
||||
| Path | Steps | req/s |
|
||||
| --- | --- | --- |
|
||||
| /steps/0 | 0 | 92,858 |
|
||||
| /steps/3 | 3 | 81,658 |
|
||||
| /steps/5 | 5 | 71,968 |
|
||||
|
||||
Each additional pipeline step costs roughly 4,178 req/s (-22.5% over 5 steps), on this box.
|
||||
|
||||
## Cost of secure-by-default (green-tea)
|
||||
|
||||
| Label | req/s |
|
||||
| --- | --- |
|
||||
| security:false (parity) | 98,912 |
|
||||
| security:true (default) | 93,178 |
|
||||
|
||||
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.
|
||||
|
||||
## Methodology
|
||||
|
||||
- **Parity controls**: every framework is configured for the fairest possible comparison —
|
||||
security-header parity (matching header sets across frameworks, or green-tea running with
|
||||
`security:false` in the cross-framework tables), keep-alive parity, and Express's `etag` and
|
||||
`x-powered-by` disabled. The `/validate` scenario always sends a valid body so every framework
|
||||
takes its success path and performs equivalent validation work.
|
||||
- **Pipeline approximation**: scenarios marked `(approximation)` (e.g. the multi-step pipeline route)
|
||||
do not have an exact one-to-one equivalent in every framework; the closest reasonable approximation
|
||||
is used for each framework and the result should be read as indicative, not as an exact apples-to-apples
|
||||
measurement.
|
||||
- **Serialization parity**: all four frameworks serialize their JSON responses with plain
|
||||
`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
|
||||
gets a serialization fast path the others lack.
|
||||
@@ -131,6 +131,17 @@ The handler signature declares exactly what it wants — in any order, nothing m
|
||||
1. **Typed functional core (`flow`)** — `flow().step(...).step(...).handle(...)`; step outputs accumulate into the context type (`Acc & Out`). This is where the compile-time guarantee lives.
|
||||
2. **Declarative decorator layer** — `@Provider/@Step/@Module/@Route/@Get/@Transformer` + argument decorators. Emits runtime metadata, builds and topologically sorts the graph, validates at boot.
|
||||
|
||||
## Benchmarks
|
||||
|
||||
Reproducible autocannon comparison vs Express 5, Fastify 5, and raw Node `http`
|
||||
lives in [BENCHMARKS.md](./BENCHMARKS.md) (regenerate with `npm run bench`).
|
||||
|
||||
Numbers are single-box + loopback — absolute req/s is overstated and
|
||||
inter-framework differences are compressed; treat cross-framework *ratios* as
|
||||
the honest signal, not the raw throughput. The cross-framework table runs
|
||||
green-tea with `security:false` for header parity; the real cost of green-tea's
|
||||
secure-by-default headers/validation is measured separately in that file.
|
||||
|
||||
## Development
|
||||
|
||||
```bash
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
{
|
||||
"env": {
|
||||
"date": "2026-07-07",
|
||||
"commit": "926ca39",
|
||||
"node": "v22.22.2",
|
||||
"os": "darwin",
|
||||
"cpu": "Apple M4 Max (16 cores)",
|
||||
"ram": "69 GB",
|
||||
"pinned": false
|
||||
},
|
||||
"config": {
|
||||
"conns": 100,
|
||||
"duration": 5,
|
||||
"runs": 3,
|
||||
"warmup": 1,
|
||||
"pipelining": 1
|
||||
},
|
||||
"scenarios": [
|
||||
{
|
||||
"title": "JSON hello (overhead)",
|
||||
"name": "hello",
|
||||
"rows": [
|
||||
{
|
||||
"framework": "raw-http",
|
||||
"reqSec": {
|
||||
"median": 115398.4,
|
||||
"min": 115078.4,
|
||||
"max": 116076.8,
|
||||
"stddev": 416.2570146222469,
|
||||
"cv": 0.003603399427582749
|
||||
},
|
||||
"p50": 0,
|
||||
"p99": 1,
|
||||
"p999": 1
|
||||
},
|
||||
{
|
||||
"framework": "fastify",
|
||||
"reqSec": {
|
||||
"median": 85881.6,
|
||||
"min": 85382.4,
|
||||
"max": 86073.6,
|
||||
"stddev": 291.32305092457597,
|
||||
"cv": 0.0033961968743538755
|
||||
},
|
||||
"p50": 1,
|
||||
"p99": 2,
|
||||
"p999": 2
|
||||
},
|
||||
{
|
||||
"framework": "express",
|
||||
"reqSec": {
|
||||
"median": 24126.4,
|
||||
"min": 24072,
|
||||
"max": 24158.4,
|
||||
"stddev": 35.66560746090835,
|
||||
"cv": 0.0014787390042501193
|
||||
},
|
||||
"p50": 3,
|
||||
"p99": 5,
|
||||
"p999": 8
|
||||
},
|
||||
{
|
||||
"framework": "green-tea",
|
||||
"reqSec": {
|
||||
"median": 98912,
|
||||
"min": 98835.2,
|
||||
"max": 99961.6,
|
||||
"stddev": 513.8455626180164,
|
||||
"cv": 0.005178001751557391
|
||||
},
|
||||
"p50": 0,
|
||||
"p99": 1,
|
||||
"p999": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Route param",
|
||||
"name": "param",
|
||||
"rows": [
|
||||
{
|
||||
"framework": "raw-http",
|
||||
"reqSec": {
|
||||
"median": 115436.8,
|
||||
"min": 115244.8,
|
||||
"max": 116012.8,
|
||||
"stddev": 326.3372488699382,
|
||||
"cv": 0.0028238464382747876
|
||||
},
|
||||
"p50": 0,
|
||||
"p99": 1,
|
||||
"p999": 1
|
||||
},
|
||||
{
|
||||
"framework": "fastify",
|
||||
"reqSec": {
|
||||
"median": 85804.8,
|
||||
"min": 85497.6,
|
||||
"max": 85856,
|
||||
"stddev": 158.26975565645782,
|
||||
"cv": 0.0018463688799174882
|
||||
},
|
||||
"p50": 1,
|
||||
"p99": 2,
|
||||
"p999": 2
|
||||
},
|
||||
{
|
||||
"framework": "express",
|
||||
"reqSec": {
|
||||
"median": 23739.2,
|
||||
"min": 23694.4,
|
||||
"max": 23777.6,
|
||||
"stddev": 33.99973856108518,
|
||||
"cv": 0.001432347940819078
|
||||
},
|
||||
"p50": 4,
|
||||
"p99": 5,
|
||||
"p999": 8
|
||||
},
|
||||
{
|
||||
"framework": "green-tea",
|
||||
"reqSec": {
|
||||
"median": 93113.6,
|
||||
"min": 92947.2,
|
||||
"max": 93126.4,
|
||||
"stddev": 81.62613960409276,
|
||||
"cv": 0.000877111912051406
|
||||
},
|
||||
"p50": 1,
|
||||
"p99": 2,
|
||||
"p999": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Pipeline (3 steps)",
|
||||
"name": "pipeline",
|
||||
"approximation": true,
|
||||
"rows": [
|
||||
{
|
||||
"framework": "raw-http",
|
||||
"reqSec": {
|
||||
"median": 114016,
|
||||
"min": 114003.2,
|
||||
"max": 114156.8,
|
||||
"stddev": 69.58722743594919,
|
||||
"cv": 0.0006101003060058202
|
||||
},
|
||||
"p50": 0,
|
||||
"p99": 1,
|
||||
"p999": 1
|
||||
},
|
||||
{
|
||||
"framework": "fastify",
|
||||
"reqSec": {
|
||||
"median": 83808,
|
||||
"min": 83769.61,
|
||||
"max": 83897.6,
|
||||
"stddev": 53.62772106538676,
|
||||
"cv": 0.0006397575458676833
|
||||
},
|
||||
"p50": 1,
|
||||
"p99": 2,
|
||||
"p999": 2
|
||||
},
|
||||
{
|
||||
"framework": "express",
|
||||
"reqSec": {
|
||||
"median": 23758.4,
|
||||
"min": 23720,
|
||||
"max": 23777.6,
|
||||
"stddev": 23.946607275352836,
|
||||
"cv": 0.001008193300579018
|
||||
},
|
||||
"p50": 4,
|
||||
"p99": 5,
|
||||
"p999": 8
|
||||
},
|
||||
{
|
||||
"framework": "green-tea",
|
||||
"reqSec": {
|
||||
"median": 84230.4,
|
||||
"min": 84179.2,
|
||||
"max": 85049.6,
|
||||
"stddev": 398.7907053413738,
|
||||
"cv": 0.004720176328277377
|
||||
},
|
||||
"p50": 1,
|
||||
"p99": 2,
|
||||
"p999": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "POST JSON + validation",
|
||||
"name": "validate",
|
||||
"rows": [
|
||||
{
|
||||
"framework": "raw-http",
|
||||
"reqSec": {
|
||||
"median": 99014.4,
|
||||
"min": 98438.4,
|
||||
"max": 99180.8,
|
||||
"stddev": 318.0885131881125,
|
||||
"cv": 0.0032169839814651393
|
||||
},
|
||||
"p50": 0,
|
||||
"p99": 1,
|
||||
"p999": 2
|
||||
},
|
||||
{
|
||||
"framework": "fastify",
|
||||
"reqSec": {
|
||||
"median": 63868.8,
|
||||
"min": 63836.8,
|
||||
"max": 64323.2,
|
||||
"stddev": 222.1331732692473,
|
||||
"cv": 0.0034703102857891206
|
||||
},
|
||||
"p50": 1,
|
||||
"p99": 2,
|
||||
"p999": 3
|
||||
},
|
||||
{
|
||||
"framework": "express",
|
||||
"reqSec": {
|
||||
"median": 19985.6,
|
||||
"min": 19886.41,
|
||||
"max": 20068.8,
|
||||
"stddev": 74.55572725597027,
|
||||
"cv": 0.003731467455443308
|
||||
},
|
||||
"p50": 4,
|
||||
"p99": 7,
|
||||
"p999": 26
|
||||
},
|
||||
{
|
||||
"framework": "green-tea",
|
||||
"reqSec": {
|
||||
"median": 76486.4,
|
||||
"min": 76396.8,
|
||||
"max": 76691.2,
|
||||
"stddev": 123.21731480058412,
|
||||
"cv": 0.0016101618664875192
|
||||
},
|
||||
"p50": 1,
|
||||
"p99": 2,
|
||||
"p999": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"stepScaling": [
|
||||
{
|
||||
"path": "/steps/0",
|
||||
"steps": 0,
|
||||
"reqSec": 92857.6
|
||||
},
|
||||
{
|
||||
"path": "/steps/3",
|
||||
"steps": 3,
|
||||
"reqSec": 81657.61
|
||||
},
|
||||
{
|
||||
"path": "/steps/5",
|
||||
"steps": 5,
|
||||
"reqSec": 71968
|
||||
}
|
||||
],
|
||||
"secureCost": [
|
||||
{
|
||||
"label": "security:false (parity)",
|
||||
"reqSec": 98912
|
||||
},
|
||||
{
|
||||
"label": "security:true (default)",
|
||||
"reqSec": 93177.6
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user