A response written in parts as it is produced, rather than serialised whole and sent with its length.
Comparable across every framework. The rows are items.medium's, so the difference from json.medium is the streaming path and a write per row.
| test | heft | request | base | what differs from the base |
|---|---|---|---|---|
| stream.ndjson | 3 | GET /stream/items | json.medium | the rows written one per line as they are produced, with no content length |
items.medium's 89 rows written one per line as application/x-ndjson. There is no Content-Length, which is what shows the body left in parts rather than buffered. Read against json.medium, the difference is the framework's streaming path and a write per row.
GET /stream/items
No body.
HTTP 200
/^application\/x-ndjson/payload items.medium, one row per line
{"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":"kitchen","priceCents":18032,"inStock":fal
… 7,915 bytes totalCompared line by line, each line as parsed JSON.
import { performanceTest } from "#kit";
import { stream } from "#payloads";
const path = "/stream/items";
export default performanceTest({
id: { family: "stream", name: "ndjson" },
path,
base: "json.medium",
varies: "streaming",
heft: 3,
about:
"items.medium's 89 rows written one per line as application/x-ndjson. " +
"There is no Content-Length, which is what shows the body left in parts " +
"rather than buffered. Read against json.medium, the difference is the " +
"framework's streaming path and a write per row.",
request: (c) => c.get(path).okWith(stream).hasHeader("content-type", /^application\/x-ndjson/).noHeader("content-length"),
});