Measure performance and allocations
Measure a real page in a known state before optimizing it. A fast home page says little about a large list, a text selection drag, or a zooming diagram.
Warm, verify, then measure
Navigate to the target, inspect its ID, complete pending transitions, and render enough frames to warm caches. Then reset counters and measure a bounded sequence. Keep screenshots outside the measured interval because capturing a figure introduces its own work.
The Debug stdio protocol supports this sequence:
{"jsonrpc":"2.0","id":1,"method":"profile.reset"}
{"jsonrpc":"2.0","id":2,"method":"app.frame","params":{"elapsedMilliseconds":16}}
{"jsonrpc":"2.0","id":3,"method":"profile.read"}
Use it after launching and inspecting the app. The response separates animation, rendering, and input managed allocations. Reset clears counters, not the GC heap or app caches.
Interpret the boundary
These counters bracket application callbacks on the UI thread. They exclude JSON parsing, protocol response construction, screenshots, native renderer setup outside the callbacks, background threads, and native memory. A zero-byte managed frame is useful evidence, not proof that the entire process did no work.
Use the separate repository allocation suite for regressions:
dotnet test Xui/Tests/Memory/Xui.Tests.Memory.csproj -c Debug
Native frame profiling is opt-in and needs a live renderable window. The optional native CLR profiler adds allocation stacks with portable-PDB locations; its overhead makes it a diagnostic tool rather than the default benchmark mode.
Remove repeated work at its owner
Cache immutable geometry and reusable buffers. Build labels when state changes instead of interpolating strings every frame. Avoid collection allocations in pointer and render callbacks. Request layout only when size or placement changed, and stop animation requests when content is idle.
Measure again using the same state and input. Keep separate budgets for different runtimes and pages. Do not trade correct ownership for a lower counter by retaining disposed views, images, or services indefinitely.