Module profiling
Expand description
Frame profiler and headless performance-testing harness for ui apps.
Measures each of the toolkit’s five frame passes (sync, build_layout,
apply_layout, draw, handle_event — see crate::widget::Widget) so
frame cost can be read off, not guessed. Three surfaces share one type
(FrameTiming): an in-app HUD (TILO_PROFILE=1, hooked into
crate::app::App’s render loop with no per-app code), a machine-readable
dump (TILO_PROFILE_OUT=<path>, JSON-lines or CSV, plus a tracing event
under tilo::profile per frame), and a headless perf harness
(run_scenario) that drives a scripted PerfScenario through the
app’s real widget passes with no GPU or display and returns a
PerfReport a test can assert on.
When neither env var is set, FrameProfiler::from_env returns None
and the render-loop hooks are Option::map over that: no clock read, no
allocation, until profiling is explicitly requested.
Live-frame diagnostics also attribute resource availability, recycled-buffer waiting, and presence overlays. Waiting is wall time, not active CPU work; none of these fields measure GPU completion or display presentation.
Structs§
- Frame
Profiler - The
crate::app::Appholds one of these behind anOption; the headlesscrate::headless::FrameHarnessholds another for the perf harness. Both feed it the same way:recorda pass duration, thencommit_frameonce per frame. - Frame
Timing - This is the atom every surface shares: the HUD graphs it, the dump
serialises it, and
PerfReportaggregates it. - Perf
Report - Per-pass and total statistics over every frame a
PerfScenarioproduced, plus how many blew the frame budget. - Perf
Scenario - Reusable across any app: build a
crate::headless::FrameHarnessover the app’s real root + state, then callrun_scenario. - Stat
Summary - For one column of measurements (a single pass, or the total), in microseconds.
Enums§
- Pass
- Attributes a measured duration to the right column of the current
frame’s
FrameTiming. - Perf
Step - Each step drives the headless driver and produces one or more measured frames.
Constants§
- FRAME_
BUDGET_ US - Rounded 60 Hz CPU-work budget. Exceeding it is a CPU diagnostic, not evidence of an actual dropped display frame.
Functions§
- run_
scenario - The driver runs the app’s real five passes with no GPU or display, so timings are of the production code path, not a mock.
- run_
scenario_ on - The one-call entry point for an app author or a test: no driver bookkeeping.