The request header map at five headers and at thirty, left unread and with three of them bound and echoed.
Comparable across every framework. The unread rows hold the count, so the bound rows minus them is the binding rather than the materialising.
A value written {run.name} is drawn once per run and never given to the framework, so it cannot answer from a table.
| test | heft | request | base | what differs from the base |
|---|---|---|---|---|
| headers.few | 1 | GET /headers | ||
| headers.bind_few | 1 | GET /headers/bind | headers.few | three request headers bound through the framework, one of them as an integer, and echoed in the response |
| headers.bind_many | 2 | GET /headers/bind | headers.bind_few | thirty request headers instead of five |
| headers.many | 2 | GET /headers | headers.few | thirty request headers instead of five |
Five request headers, none of which the handler reads. Two of the five are what an HTTP client adds itself, and the other three are the ones the binding rows bind. This is what headers.many is subtracted from.
GET /headers
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 = "/headers";
export default performanceTest({
id: { family: "headers", name: "few" },
path,
heft: 1,
about:
"Five request headers, none of which the handler reads. Two of the five " +
"are what an HTTP client adds itself, and the other three are the ones " +
"the binding rows bind. This is what headers.many is subtracted from.",
request: (c) =>
c
.get(path)
.header("x-rb-tenant", c.run.tenant)
.header("x-rb-request-id", c.run.requestId)
.header("x-rb-account", String(c.run.account))
.okWith(items.small),
});
The same five headers with three of them bound through the framework and written back, one as an integer. Read against headers.few, the difference is the binding rather than the materialising.
GET /headers/bind
No body.
HTTP 200
payload items.small
{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}],"echo":{"tenant":"{run.tenant}","requestId":"{run.requestId}","account":{run.account}}}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 = "/headers/bind";
export default performanceTest({
id: { family: "headers", name: "bind_few" },
path,
base: "headers.few",
varies: "header_binding",
heft: 1,
about:
"The same five headers with three of them bound through the framework and " +
"written back, one as an integer. Read against headers.few, the " +
"difference is the binding rather than the materialising.",
request: (c) =>
c
.get(path)
.header("x-rb-tenant", c.run.tenant)
.header("x-rb-request-id", c.run.requestId)
.header("x-rb-account", String(c.run.account))
.okWith(items.small, { echo: ["tenant", "requestId", "account"] }),
});
Three headers bound out of thirty instead of out of five. Read against headers.bind_few, the difference is whether a framework's binder pays for the headers it was not asked about.
GET /headers/bind
No body.
HTTP 200
payload items.small
{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}],"echo":{"tenant":"{run.tenant}","requestId":"{run.requestId}","account":{run.account}}}Compared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { items } from "#payloads";
import { BROWSER_AND_PROXY } from "#models/fixture";
const path = "/headers/bind";
export default performanceTest({
id: { family: "headers", name: "bind_many" },
path,
base: "headers.bind_few",
varies: "header_count",
heft: 2,
about:
"Three headers bound out of thirty instead of out of five. Read against " +
"headers.bind_few, the difference is whether a framework's binder pays " +
"for the headers it was not asked about.",
request: (c) => {
let call = c
.get(path)
.header("x-rb-tenant", c.run.tenant)
.header("x-rb-request-id", c.run.requestId)
.header("x-rb-account", String(c.run.account));
for (const [name, value] of BROWSER_AND_PROXY) call = call.header(name, value);
return call.okWith(items.small, { echo: ["tenant", "requestId", "account"] });
},
});
Thirty request headers, still read by nothing. Read against headers.few, the difference is the cost of materialising twenty-five more that nobody asked for, which is about a kilobyte and close to what a real request carries.
GET /headers
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";
import { BROWSER_AND_PROXY } from "#models/fixture";
const path = "/headers";
export default performanceTest({
id: { family: "headers", name: "many" },
path,
base: "headers.few",
varies: "header_count",
heft: 2,
about:
"Thirty request headers, still read by nothing. Read against headers.few, " +
"the difference is the cost of materialising twenty-five more that nobody " +
"asked for, which is about a kilobyte and close to what a real request " +
"carries.",
request: (c) => {
let call = c
.get(path)
.header("x-rb-tenant", c.run.tenant)
.header("x-rb-request-id", c.run.requestId)
.header("x-rb-account", String(c.run.account));
for (const [name, value] of BROWSER_AND_PROXY) call = call.header(name, value);
return call.okWith(items.small);
},
});