← tests

static

The framework's static-file feature, serving committed files from the payload directory.

Comparable across every framework. The files are items.small.json, items.medium.json and items.large.json, so read against the json row of the same size the difference is the file served against the same rows serialised.

testheftrequestbasewhat differs from the base
static.large4GET /static/items.large.jsonjson.largethe published file served by the static-file feature instead of serialized
static.medium2GET /static/items.medium.jsonjson.mediumthe published file served by the static-file feature instead of serialized
static.small1GET /static/items.small.jsonjson.smallthe published file served by the static-file feature instead of serialized

static.large

heft 4

base json.large

items.large.json sent by the framework's static-file feature from the payload directory, with its modification time. The request accepts gzip, as a browser's does, and the body is compared byte for byte after decoding, so the file may go out as it is or compressed. This is the one family where serving the file's bytes is the point. Last-Modified is checked rather than an ETag, because Go's file server sends no ETag.

Request

GET /static/items.large.json
accept-encodinggzip

No body.

Expected response

HTTP 200
content-typematches /^application\/json/
last-modifiedis present

payload items.large.json

{"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","catego
… 129,937 bytes total

Compared byte for byte.

Test source, tests/static/large.ts
tests/static/large.tsopen on GitHub →
import { performanceTest } from "#kit";
import { files } from "#payloads";

const path = "/static/items.large.json";

export default performanceTest({
  id: { family: "static", name: "large" },
  path,
  base: "json.large",
  varies: "static_file",
  heft: 4,
  about:
    "items.large.json sent by the framework's static-file feature from the " +
    "payload directory, with its modification time. The request accepts gzip, " +
    "as a browser's does, and the body is compared byte for byte after " +
    "decoding, so the file may go out as it is or compressed. This is the one " +
    "family where serving the file's bytes is the point. Last-Modified is " +
    "checked rather than an ETag, because Go's file server sends no ETag.",

  request: (c) =>
    c
      .get(path)
      .header("accept-encoding", "gzip")
      .okWith(files.large)
      .hasHeader("content-type", /^application\/json/)
      .hasHeader("last-modified"),
});

static.medium

heft 2

base json.medium

items.medium.json sent by the same static-file feature, with its modification time, to a request that accepts gzip. Read against json.medium, the difference is the file served against the same 89 rows serialised, and against static.small it is the feature's cost per byte.

Request

GET /static/items.medium.json
accept-encodinggzip

No body.

Expected response

HTTP 200
content-typematches /^application\/json/
last-modifiedis present

payload items.medium.json

{"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","categor
… 8,044 bytes total

Compared byte for byte.

Test source, tests/static/medium.ts
tests/static/medium.tsopen on GitHub →
import { performanceTest } from "#kit";
import { files } from "#payloads";

const path = "/static/items.medium.json";

export default performanceTest({
  id: { family: "static", name: "medium" },
  path,
  base: "json.medium",
  varies: "static_file",
  heft: 2,
  about:
    "items.medium.json sent by the same static-file feature, with its " +
    "modification time, to a request that accepts gzip. Read against " +
    "json.medium, the difference is the file served against the same 89 rows " +
    "serialised, and against static.small it is the feature's cost per byte.",

  request: (c) =>
    c
      .get(path)
      .header("accept-encoding", "gzip")
      .okWith(files.medium)
      .hasHeader("content-type", /^application\/json/)
      .hasHeader("last-modified"),
});

static.small

heft 1

base json.small

items.small.json sent by the same static-file feature, with its modification time, to a request that accepts gzip. The file is one row, so what is left is the feature's own cost per request: finding the file, reading its metadata and writing its headers.

Request

GET /static/items.small.json
accept-encodinggzip

No body.

Expected response

HTTP 200
content-typematches /^application\/json/
last-modifiedis present

payload items.small.json

{"size":"small","count":1,"items":[
{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}
]}

Compared byte for byte.

Test source, tests/static/small.ts
tests/static/small.tsopen on GitHub →
import { performanceTest } from "#kit";
import { files } from "#payloads";

const path = "/static/items.small.json";

export default performanceTest({
  id: { family: "static", name: "small" },
  path,
  base: "json.small",
  varies: "static_file",
  heft: 1,
  about:
    "items.small.json sent by the same static-file feature, with its " +
    "modification time, to a request that accepts gzip. The file is one row, " +
    "so what is left is the feature's own cost per request: finding the file, " +
    "reading its metadata and writing its headers.",

  request: (c) =>
    c
      .get(path)
      .header("accept-encoding", "gzip")
      .okWith(files.small)
      .hasHeader("content-type", /^application\/json/)
      .hasHeader("last-modified"),
});