Documentation
¶
Overview ¶
perfscenes measures whole-app frame cost on scenes real apps are made of, the ones a Fyne comparison reported as regressions (#427). Unit benchmarks cannot see these: the cost is in a full paint of a full window.
Build and run from the repository root:
go run ./hack/perfscenes -scene spinner -n 100
Scenes:
- shapes: n rectangles and circles (default 20000), all moved every frame
- labels: n labels in a scroll container (default 2000), all re-texted every frame
- tiles: n cards with a label, progress bar and button (default 500), all updated every frame
- spinner: the same n cards left static, plus one infinite progress bar
The window is 1920×1080. -screen opens it on the display whose name contains the given text, shrunk to fit, to measure that display's frame rate (#486). One mutation is applied per painted frame: a 1×1 raster refreshed with each mutation marks when a frame was painted. After a warm-up, one line is printed:
RESULT scene=... frames=... fps=... mean_ms=... p99_ms=... cpu_ms_per_frame=...
alloc_kb_per_frame=... allocs_per_frame=... heap_mb=... maxrss_mb=... gc=...
-memprofile writes two allocation profiles: the given file at the end of the measured window and file.base at its start. An allocation profile counts from the start of the process, so read the window's allocations as the difference; the file alone also counts startup (#446):
go tool pprof -diff_base mem.prof.base mem.prof
cpu_ms_per_frame counts every thread of the process, so it can exceed mean_ms. On a vsync'd display fps is capped at the refresh rate, which makes cpu_ms_per_frame the better cost figure for cheap scenes.
The same program builds against Fyne by renaming the imports (bellui → fyne.io/fyne/v2), core.CanvasObject → fyne.CanvasObject and geo.NewSize/NewPos → fyne.NewSize/NewPos, and replacing Show + Run with ShowAndRun.