Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions doc/2026-10-27T00-00-00Z_baseline_bytes_per_frame.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# F11.9 — Bytes-per-frame baseline table

- Status: baseline record
- Date: 2026-10-27
- Issue: developing-today/code#542
- Measured at commit: `37418e56339c315cf0ddf3e61c9c55c1e9d0c0a2` (main, 2026-10-27)
- Measurement: `pkgs/id/src/sandbox.rs` test `bytes_per_frame_baseline_for_checked_in_examples`

## What is measured

For each checked-in example wasm in `pkgs/id/examples/`, the guest is
instantiated in the `Sandbox` with a fixed seed (7) and the full-screen
frame byte length at rest is recorded via `layout_at(width, height)` at
the two reference viewports, 80x24 and 200x60.

The baseline is the guest frame bytes **at the sandbox boundary** — the
number Phase 12 delta frames (F12.11) and server-side redraw batching
must beat at the source. Presenter wire encodings (surface JSON / ANSI)
are out of scope for this baseline and are not measured here.

## Baseline table (seed 7, at rest)

| example | plaza_layout | bytes @ 80x24 | bytes @ 200x60 |
| ----------- | ------------ | ------------: | -------------: |
| lounge | yes | 29 | 29 |
| roc-chat | yes | 24 | 24 |
| roc-counter | yes | 7 | 7 |
| roc-grid | yes | 383 | 383 |
| roc-screen | yes | 179 | 179 |
| territory | yes | 1010 | 1010 |
| tic-tac-toe | yes | 25 | 25 |

Notes:

- All seven examples export `plaza_layout`, so no guest used the
`view()` fallback in this run. The measurement test asserts the
fallback invariant (identical bytes at both viewports, equal to
`view()`) for any future guest without the export, and the printed
table marks such guests `no (view fallback)`.
- At rest, every example's frame is the same byte length at both
viewports: the initial frames do not fill the larger viewport. That
equality is itself a baseline datum — it is the starting point delta
frames are compared against, not a measurement error (the test calls
`layout_at` separately for each viewport).

## How to rerun

```sh
cd pkgs/id && cargo test --lib bytes_per_frame_baseline -- --nocapture
```

The test prints the table above (one row per example) and passes when
every example instantiates and renders within the default sandbox
limits. Update this file's table and measured-at commit when a rerun
produces different numbers.
62 changes: 62 additions & 0 deletions pkgs/id/src/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,68 @@ mod tests {
assert_eq!(width_of(live.view().unwrap()), 20);
}

#[test]
fn bytes_per_frame_baseline_for_checked_in_examples() {
// F11.9 baseline: the full-screen frame size each checked-in example
// produces at rest (seed 7), at the two reference viewports. These
// numbers are the baseline Phase 12 delta frames (F12.11) must beat;
// the committed table lives in
// doc/2026-10-27T00-00-00Z_baseline_bytes_per_frame.md.
// Rerun with:
// cd pkgs/id && cargo test --lib bytes_per_frame_baseline -- --nocapture
const EXAMPLES: [(&str, &[u8]); 7] = [
("lounge", include_bytes!("../examples/lounge/lounge.wasm")),
(
"roc-chat",
include_bytes!("../examples/roc-chat/roc-chat.wasm"),
),
(
"roc-counter",
include_bytes!("../examples/roc-counter/counter.wasm"),
),
(
"roc-grid",
include_bytes!("../examples/roc-grid/roc-grid.wasm"),
),
(
"roc-screen",
include_bytes!("../examples/roc-screen/roc-screen.wasm"),
),
(
"territory",
include_bytes!("../examples/territory/territory.wasm"),
),
(
"tic-tac-toe",
include_bytes!("../examples/tic-tac-toe/tic-tac-toe.wasm"),
),
];
println!("| example | plaza_layout | bytes @ 80x24 | bytes @ 200x60 |");
for (name, wasm) in EXAMPLES {
let runner = Sandbox::compile(wasm, SandboxLimits::default()).unwrap();
let mut live = runner.instantiate(7).unwrap();
let has_layout = live.layout.is_some();
let small = live.layout_at(80, 24).unwrap();
let large = live.layout_at(200, 60).unwrap();
println!(
"| {name} | {} | {} | {} |",
if has_layout {
"yes"
} else {
"no (view fallback)"
},
small.len(),
large.len()
);
if !has_layout {
// Without `plaza_layout`, layout_at falls back to view():
// the frame is the same bytes at both viewports.
assert_eq!(small, large, "{name}: view fallback must not reflow");
assert_eq!(small, live.view().unwrap(), "{name}: fallback is view()");
}
}
}

#[test]
fn checked_in_territory_renders_a_styled_screen_within_the_default_fuel() {
let wasm = include_bytes!("../examples/territory/territory.wasm");
Expand Down
Loading