Benchmark findings¶
Current observations:
- around
~2kobjects: smooth - around
100kvisible rectangles: not smooth
Likely bottlenecks:
- drawing every rect every frame
- per-rect transform math every frame
- per-rect
Rectallocation every frame - repainting more UI than just the canvas subtree
Best likely wins for the later performance pass:
- add viewport culling
- switch to canvas-level translate/scale
- precompute world-space
Rects after load - keep repaint scope small
- disable antialiasing for plain axis-aligned rects
What to measure after each change:
- static frame time
- pan smoothness
- zoom smoothness
- behavior when fully zoomed out
- visible object count
Important note:
At 100k visible rects, immediate-mode drawing may still struggle depending on platform and zoom level.
The main performance goal is to reduce draw count, per-frame CPU math, and per-frame allocations.
Tip
lib/features/benchmark/benchmark_painter.dart:22
Even with BenchRenderObject.rect precomputed, paint() still allocates a new Rect for every object on every frame
(and repeats per-object transform math). If the goal of introducing render data is to reduce per-frame CPU/allocations,
consider applying canvas.translate(pan.dx, pan.dy) + canvas.scale(zoom) once and then drawing the precomputed world-space
rects directly
Comparison¶
3a289fd

Raster max 14.1ms/frame, avg 8.2 ms/frame UI max 47.4ms/frame, avg 22.4ms/frame