Server-sent events: a text/event-stream response written event by event through the framework's own support for it.
Comparable across every framework. A framework with no support of its own writes the events by hand, and says so in its README. The events carry stream.ndjson's rows, so the difference from it is the event framing.
| test | heft | request | base | what differs from the base |
|---|---|---|---|---|
| sse.medium | 3 | GET /sse/medium | stream.ndjson | the rows sent as server-sent events through the framework's own support for them, instead of as lines |
items.medium's 89 rows, each the data of one server-sent event. The request carries the Accept header an EventSource sends. Every event is of type message with no id, and there is no Content-Length. Read against stream.ndjson, the difference is the framework's event framing against a line per row.
GET /sse/medium
No body.
HTTP 200
/^text\/event-stream/payload items.medium, one row per event
data: {"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}
data: {"id":2,"name":"brass-hinge-5716","category":"garden","priceCents":17577,"inStock":true}
data: {"id":3,"name":"linen-ring-6971","category":"kitchen","priceCents":5540,"inStock":true}
data: {"id":4,"name":"copper-bolt-9217","category":"outdoor","priceCents":11562,"inStock":true}
data: {"id":5,"name":"linen-lamp-8288","category":"office","priceCents":1413,"inStock":true}
data: {"id":6,"name":"copper-pan-9308","category":"tools","priceCents":10795,"inStock":true}
data: {"id":7,"name":"slate-seed-3051","category":"garden","priceCents":9667,"inStock":false}
data: {"id":8,"name":"oak-lamp-8662
… 8,538 bytes totalCompared event by event as an EventSource dispatches them: each of type message with no id, and its data as parsed JSON.
import { performanceTest } from "#kit";
import { sse } from "#payloads";
const path = "/sse/medium";
export default performanceTest({
id: { family: "sse", name: "medium" },
path,
base: "stream.ndjson",
varies: "event_stream",
heft: 3,
about:
"items.medium's 89 rows, each the data of one server-sent event. The request " +
"carries the Accept header an EventSource sends. Every event is of type " +
"message with no id, and there is no Content-Length. Read against " +
"stream.ndjson, the difference is the framework's event framing against a " +
"line per row.",
request: (c) =>
c
.get(path)
.header("accept", "text/event-stream")
.okWith(sse)
.hasHeader("content-type", /^text\/event-stream/)
.noHeader("content-length"),
});