Serialising a body the framework already holds, across three size regimes.
Comparable across every framework at one size, and across the three sizes as a set. The small row against the large one is what separates a framework with a fast codec from one with a fast request path.
| test | heft | request | base | what differs from the base |
|---|---|---|---|---|
| json.small | 1 | GET /json/small | ||
| json.large | 4 | GET /json/large | json.small | a larger response body, same route and same handler |
| json.medium | 2 | GET /json/medium | json.small | a larger response body, same route and same handler |
One row out, serialised from a body the framework already holds. The plainest question in the corpus once something has to be serialised. Read against baseline.plaintext, the difference is the codec.
GET /json/small
No body.
HTTP 200
payload items.small
{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}]}Compared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { items } from "#payloads";
const path = "/json/small";
export default performanceTest({
id: { family: "json", name: "small" },
path,
heft: 1,
about:
"One row out, serialised from a body the framework already holds. The " +
"plainest question in the corpus once something has to be serialised. " +
"Read against baseline.plaintext, the difference is the codec.",
request: (c) => c.get(path).okWith(items.small),
});
Fourteen hundred rows out, serialised from a body the framework already holds. The size at which the writer stops being free. Read against json.small, the pair is what separates a framework with a fast codec from one with a fast request path.
GET /json/large
No body.
HTTP 200
payload items.large
{"size":"large","count":1425,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true},{"id":2,"name":"brass-hinge-5716","category":"garden","priceCents":17577,"inStock":true},{"id":3,"name":"linen-ring-6971","category":"kitchen","priceCents":5540,"inStock":true},{"id":4,"name":"copper-bolt-9217","category":"outdoor","priceCents":11562,"inStock":true},{"id":5,"name":"linen-lamp-8288","category":"office","priceCents":1413,"inStock":true},{"id":6,"name":"copper-pan-9308","category":"tools","priceCents":10795,"inStock":true},{"id":7,"name":"slate-seed-3051","category":"garden","priceCents":9667,"inStock":false},{"id":8,"name":"oak-lamp-8662","category":"kit
… 128,510 bytes totalCompared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { items } from "#payloads";
const path = "/json/large";
export default performanceTest({
id: { family: "json", name: "large" },
path,
base: "json.small",
varies: "size",
heft: 4,
about:
"Fourteen hundred rows out, serialised from a body the framework already " +
"holds. The size at which the writer stops being free. Read against " +
"json.small, the pair is what separates a framework with a fast codec " +
"from one with a fast request path.",
request: (c) => c.get(path).okWith(items.large),
});
Eighty-nine rows out, serialised from a body the framework already holds. The middle size, where the codec is doing real work and the response still fits a single write. Read against json.small rather than on its own.
GET /json/medium
No body.
HTTP 200
payload items.medium
{"size":"medium","count":89,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true},{"id":2,"name":"brass-hinge-5716","category":"garden","priceCents":17577,"inStock":true},{"id":3,"name":"linen-ring-6971","category":"kitchen","priceCents":5540,"inStock":true},{"id":4,"name":"copper-bolt-9217","category":"outdoor","priceCents":11562,"inStock":true},{"id":5,"name":"linen-lamp-8288","category":"office","priceCents":1413,"inStock":true},{"id":6,"name":"copper-pan-9308","category":"tools","priceCents":10795,"inStock":true},{"id":7,"name":"slate-seed-3051","category":"garden","priceCents":9667,"inStock":false},{"id":8,"name":"oak-lamp-8662","category":"kitc
… 7,953 bytes totalCompared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { items } from "#payloads";
const path = "/json/medium";
export default performanceTest({
id: { family: "json", name: "medium" },
path,
base: "json.small",
varies: "size",
heft: 2,
about:
"Eighty-nine rows out, serialised from a body the framework already " +
"holds. The middle size, where the codec is doing real work and the " +
"response still fits a single write. Read against json.small rather than " +
"on its own.",
request: (c) => c.get(path).okWith(items.medium),
});