The parser and the validator, with size crossed against validation.
Comparable across every framework. Bind parses without validating, so validate minus bind is the validator alone rather than the validator plus the parse.
A refusal's status is written 4XX. Frameworks refuse with different statuses, so each declares its own in its client-exception, and the test reads it from there.
| test | heft | request | base | what differs from the base |
|---|---|---|---|---|
| body.bind_small | 2 | POST /body/bind/small | ||
| body.bind_medium | 3 | POST /body/bind/medium | body.bind_small | a larger response body, same route and same handler |
| body.bind_large | 4 | POST /body/bind/large | body.bind_medium | a larger response body, same route and same handler |
| body.validate_large | 5 | POST /body/validate/large | body.bind_large | the bound body checked against a schema |
| body.validate_medium | 3 | POST /body/validate/medium | body.bind_medium | the bound body checked against a schema |
| body.validate_small | 2 | POST /body/validate/small | body.bind_small | the bound body checked against a schema |
| body.rejected_all | 2 | POST /body/validate/small | body.validate_small | the request refused rather than served |
| body.rejected_first | 2 | POST /body/validate/first-error | body.rejected_all | the first field error reported instead of all of them |
A body parsed and bound without being validated. The answer carries a count of the leaves it found, which is what says the request was parsed rather than piped to the response. This is what the validate row of the same size is subtracted from.
POST /body/bind/small
payload order.small
{"customerId":1,"status":"open","lines":[{"productId":1,"qty":1}]}HTTP 200
payload bind.small
{"fields":4,"bytes":66,"echo":{"customerId":1,"status":"open","lines":[{"productId":1,"qty":1}]}}Compared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { bind, order } from "#payloads";
const path = "/body/bind/small";
export default performanceTest({
id: { family: "body", name: "bind_small" },
path,
heft: 2,
about:
"A body parsed and bound without being validated. The answer carries a " +
"count of the leaves it found, which is what says the request was parsed " +
"rather than piped to the response. This is what the validate row of the " +
"same size is subtracted from.",
request: (c) => c.post(path, order.small.value).okWith(bind.small),
});
A body parsed and bound without being validated. The answer carries a count of the leaves it found, which is what says the request was parsed rather than piped to the response. This is what the validate row of the same size is subtracted from.
POST /body/bind/medium
payload order.medium
{"customerId":1,"status":"open","lines":[{"productId":1,"qty":1},{"productId":2,"qty":2},{"productId":3,"qty":3},{"productId":4,"qty":4},{"productId":5,"qty":5},{"productId":6,"qty":1},{"productId":7,"qty":2},{"productId":8,"qty":3},{"productId":9,"qty":4},{"productId":10,"qty":5},{"productId":11,"qty":1},{"productId":12,"qty":2},{"productId":13,"qty":3},{"productId":14,"qty":4},{"productId":15,"qty":5},{"productId":16,"qty":1},{"productId":17,"qty":2},{"productId":18,"qty":3},{"productId":19,"qty":4},{"productId":20,"qty":5},{"productId":21,"qty":1},{"productId":22,"qty":2},{"productId":23,"qty":3},{"productId":24,"qty":4},{"productId":25,"qty":5},{"productId":26,"qty":1},{"productId":27,"q
… 8,379 bytes totalHTTP 200
payload bind.medium
{"fields":674,"bytes":8379,"echo":{"customerId":1,"status":"open","lines":[{"productId":1,"qty":1},{"productId":2,"qty":2},{"productId":3,"qty":3},{"productId":4,"qty":4},{"productId":5,"qty":5},{"productId":6,"qty":1},{"productId":7,"qty":2},{"productId":8,"qty":3},{"productId":9,"qty":4},{"productId":10,"qty":5},{"productId":11,"qty":1},{"productId":12,"qty":2},{"productId":13,"qty":3},{"productId":14,"qty":4},{"productId":15,"qty":5},{"productId":16,"qty":1},{"productId":17,"qty":2},{"productId":18,"qty":3},{"productId":19,"qty":4},{"productId":20,"qty":5},{"productId":21,"qty":1},{"productId":22,"qty":2},{"productId":23,"qty":3},{"productId":24,"qty":4},{"productId":25,"qty":5},{"product
… 8,414 bytes totalCompared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { bind, order } from "#payloads";
const path = "/body/bind/medium";
export default performanceTest({
id: { family: "body", name: "bind_medium" },
path,
base: "body.bind_small",
varies: "size",
heft: 3,
about:
"A body parsed and bound without being validated. The answer carries a " +
"count of the leaves it found, which is what says the request was parsed " +
"rather than piped to the response. This is what the validate row of the " +
"same size is subtracted from.",
request: (c) => c.post(path, order.medium.value).okWith(bind.medium),
});
A body parsed and bound without being validated, at about 40 KB. The answer carries a count of the leaves it found, which is what says the request was parsed rather than piped to the response. Read against body.bind_medium, the difference is the parser and the binder at scale.
POST /body/bind/large
payload order.large
{"customerId":1,"status":"open","lines":[{"productId":1,"qty":1},{"productId":2,"qty":2},{"productId":3,"qty":3},{"productId":4,"qty":4},{"productId":5,"qty":5},{"productId":6,"qty":1},{"productId":7,"qty":2},{"productId":8,"qty":3},{"productId":9,"qty":4},{"productId":10,"qty":5},{"productId":11,"qty":1},{"productId":12,"qty":2},{"productId":13,"qty":3},{"productId":14,"qty":4},{"productId":15,"qty":5},{"productId":16,"qty":1},{"productId":17,"qty":2},{"productId":18,"qty":3},{"productId":19,"qty":4},{"productId":20,"qty":5},{"productId":21,"qty":1},{"productId":22,"qty":2},{"productId":23,"qty":3},{"productId":24,"qty":4},{"productId":25,"qty":5},{"productId":26,"qty":1},{"productId":27,"q
… 39,754 bytes totalHTTP 200
payload bind.large
{"fields":3202,"bytes":39754,"echo":{"customerId":1,"status":"open","lines":[{"productId":1,"qty":1},{"productId":2,"qty":2},{"productId":3,"qty":3},{"productId":4,"qty":4},{"productId":5,"qty":5},{"productId":6,"qty":1},{"productId":7,"qty":2},{"productId":8,"qty":3},{"productId":9,"qty":4},{"productId":10,"qty":5},{"productId":11,"qty":1},{"productId":12,"qty":2},{"productId":13,"qty":3},{"productId":14,"qty":4},{"productId":15,"qty":5},{"productId":16,"qty":1},{"productId":17,"qty":2},{"productId":18,"qty":3},{"productId":19,"qty":4},{"productId":20,"qty":5},{"productId":21,"qty":1},{"productId":22,"qty":2},{"productId":23,"qty":3},{"productId":24,"qty":4},{"productId":25,"qty":5},{"produ
… 39,791 bytes totalCompared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { bind, order } from "#payloads";
const path = "/body/bind/large";
export default performanceTest({
id: { family: "body", name: "bind_large" },
path,
base: "body.bind_medium",
varies: "size",
heft: 4,
about:
"A body parsed and bound without being validated, at about 40 KB. The " +
"answer carries a count of the leaves it found, which is what says the " +
"request was parsed rather than piped to the response. Read against " +
"body.bind_medium, the difference is the parser and the binder at scale.",
request: (c) => c.post(path, order.large.value).okWith(bind.large),
});
The same body checked against a schema before the handler sees it, and answered exactly as the bind row answers it. Read against body.bind_large, the difference is the validator alone rather than the validator plus the parse.
POST /body/validate/large
payload order.large
{"customerId":1,"status":"open","lines":[{"productId":1,"qty":1},{"productId":2,"qty":2},{"productId":3,"qty":3},{"productId":4,"qty":4},{"productId":5,"qty":5},{"productId":6,"qty":1},{"productId":7,"qty":2},{"productId":8,"qty":3},{"productId":9,"qty":4},{"productId":10,"qty":5},{"productId":11,"qty":1},{"productId":12,"qty":2},{"productId":13,"qty":3},{"productId":14,"qty":4},{"productId":15,"qty":5},{"productId":16,"qty":1},{"productId":17,"qty":2},{"productId":18,"qty":3},{"productId":19,"qty":4},{"productId":20,"qty":5},{"productId":21,"qty":1},{"productId":22,"qty":2},{"productId":23,"qty":3},{"productId":24,"qty":4},{"productId":25,"qty":5},{"productId":26,"qty":1},{"productId":27,"q
… 39,754 bytes totalHTTP 200
payload bind.large
{"fields":3202,"bytes":39754,"echo":{"customerId":1,"status":"open","lines":[{"productId":1,"qty":1},{"productId":2,"qty":2},{"productId":3,"qty":3},{"productId":4,"qty":4},{"productId":5,"qty":5},{"productId":6,"qty":1},{"productId":7,"qty":2},{"productId":8,"qty":3},{"productId":9,"qty":4},{"productId":10,"qty":5},{"productId":11,"qty":1},{"productId":12,"qty":2},{"productId":13,"qty":3},{"productId":14,"qty":4},{"productId":15,"qty":5},{"productId":16,"qty":1},{"productId":17,"qty":2},{"productId":18,"qty":3},{"productId":19,"qty":4},{"productId":20,"qty":5},{"productId":21,"qty":1},{"productId":22,"qty":2},{"productId":23,"qty":3},{"productId":24,"qty":4},{"productId":25,"qty":5},{"produ
… 39,791 bytes totalCompared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { bind, order } from "#payloads";
const path = "/body/validate/large";
export default performanceTest({
id: { family: "body", name: "validate_large" },
path,
base: "body.bind_large",
varies: "validation",
heft: 5,
about:
"The same body checked against a schema before the handler sees it, and " +
"answered exactly as the bind row answers it. Read against " +
"body.bind_large, the difference is the validator alone rather than the " +
"validator plus the parse.",
request: (c) => c.post(path, order.large.value).okWith(bind.large),
});
The same body checked against a schema before the handler sees it, and answered exactly as the bind row answers it. Read against body.bind_medium, the difference is the validator alone rather than the validator plus the parse.
POST /body/validate/medium
payload order.medium
{"customerId":1,"status":"open","lines":[{"productId":1,"qty":1},{"productId":2,"qty":2},{"productId":3,"qty":3},{"productId":4,"qty":4},{"productId":5,"qty":5},{"productId":6,"qty":1},{"productId":7,"qty":2},{"productId":8,"qty":3},{"productId":9,"qty":4},{"productId":10,"qty":5},{"productId":11,"qty":1},{"productId":12,"qty":2},{"productId":13,"qty":3},{"productId":14,"qty":4},{"productId":15,"qty":5},{"productId":16,"qty":1},{"productId":17,"qty":2},{"productId":18,"qty":3},{"productId":19,"qty":4},{"productId":20,"qty":5},{"productId":21,"qty":1},{"productId":22,"qty":2},{"productId":23,"qty":3},{"productId":24,"qty":4},{"productId":25,"qty":5},{"productId":26,"qty":1},{"productId":27,"q
… 8,379 bytes totalHTTP 200
payload bind.medium
{"fields":674,"bytes":8379,"echo":{"customerId":1,"status":"open","lines":[{"productId":1,"qty":1},{"productId":2,"qty":2},{"productId":3,"qty":3},{"productId":4,"qty":4},{"productId":5,"qty":5},{"productId":6,"qty":1},{"productId":7,"qty":2},{"productId":8,"qty":3},{"productId":9,"qty":4},{"productId":10,"qty":5},{"productId":11,"qty":1},{"productId":12,"qty":2},{"productId":13,"qty":3},{"productId":14,"qty":4},{"productId":15,"qty":5},{"productId":16,"qty":1},{"productId":17,"qty":2},{"productId":18,"qty":3},{"productId":19,"qty":4},{"productId":20,"qty":5},{"productId":21,"qty":1},{"productId":22,"qty":2},{"productId":23,"qty":3},{"productId":24,"qty":4},{"productId":25,"qty":5},{"product
… 8,414 bytes totalCompared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { bind, order } from "#payloads";
const path = "/body/validate/medium";
export default performanceTest({
id: { family: "body", name: "validate_medium" },
path,
base: "body.bind_medium",
varies: "validation",
heft: 3,
about:
"The same body checked against a schema before the handler sees it, and " +
"answered exactly as the bind row answers it. Read against " +
"body.bind_medium, the difference is the validator alone rather than the " +
"validator plus the parse.",
request: (c) => c.post(path, order.medium.value).okWith(bind.medium),
});
The same body checked against a schema before the handler sees it, and answered exactly as the bind row answers it. Read against body.bind_small, the difference is the validator alone rather than the validator plus the parse.
POST /body/validate/small
payload order.small
{"customerId":1,"status":"open","lines":[{"productId":1,"qty":1}]}HTTP 200
payload bind.small
{"fields":4,"bytes":66,"echo":{"customerId":1,"status":"open","lines":[{"productId":1,"qty":1}]}}Compared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { bind, order } from "#payloads";
const path = "/body/validate/small";
export default performanceTest({
id: { family: "body", name: "validate_small" },
path,
base: "body.bind_small",
varies: "validation",
heft: 2,
about:
"The same body checked against a schema before the handler sees it, and " +
"answered exactly as the bind row answers it. Read against " +
"body.bind_small, the difference is the validator alone rather than the " +
"validator plus the parse.",
request: (c) => c.post(path, order.small.value).okWith(bind.small),
});
Three fields wrong in one body. What a rejection looks like is the framework's own contract, so the status and the field paths are read through its exceptions declaration and this test never sees an error body.
POST /body/validate/small
payload order.invalid
{"customerId":0,"status":"","lines":[]}HTTP 4XX
The status the framework declares as rejected in its client-exception.
The framework's own error body, read through its client-exception. It has to name customerId, status and lines, or exactly one of them where the framework declares that it reports only the first error.
import { performanceTest } from "#kit";
import { order } from "#payloads";
const path = "/body/validate/small";
export default performanceTest({
id: { family: "body", name: "rejected_all" },
path,
base: "body.validate_small",
varies: "outcome",
heft: 2,
about:
"Three fields wrong in one body. What a rejection looks like is the " +
"framework's own contract, so the status and the field paths are read " +
"through its exceptions declaration and this test never sees an error " +
"body.",
request: (c) => c.post(path, order.invalid.value).rejected("customerId", "status", "lines"),
});
The same body against a route that stops at the first bad field. Read against body.rejected_all, the difference is the two error contracts: one walks the whole object and one gives up, and the second is doing less work.
POST /body/validate/first-error
payload order.invalid
{"customerId":0,"status":"","lines":[]}HTTP 4XX
The status the framework declares as rejected in its client-exception.
The framework's own error body, read through its client-exception. It has to name customerId.
import { performanceTest } from "#kit";
import { order } from "#payloads";
const path = "/body/validate/first-error";
export default performanceTest({
id: { family: "body", name: "rejected_first" },
path,
base: "body.rejected_all",
varies: "error_contract",
heft: 2,
about:
"The same body against a route that stops at the first bad field. Read " +
"against body.rejected_all, the difference is the two error contracts: " +
"one walks the whole object and one gives up, and the second is doing " +
"less work.",
request: (c) => c.post(path, order.invalid.value).rejected("customerId"),
});