Guides/Performance

Performance

Cell-level diff, grapheme width, and cached component models beat reprinting the whole screen every frame. Run the benches locally to see naive Dart vs dart_tui, and kernel/AOT first-visible startup.

Why not print every frame

Reprint-the-screen loops pay for every cell on every tick. dart_tui writes only cells that changed, measures grapheme width without reallocating on every call, and keeps cached row models in components like TextArea and Viewport so update/view work stays cheap.

Run the benches

bash
make bench-hotpath
make bench-startup-pty
WorkloadNaivedart_tuiRatio
getWidth plain x1000030080 µs2511 µs12.0x
getWidth ANSI x1000033792 µs3353 µs10.1x
textarea update+view x30019733 µs3752 µs5.3x
viewport soft-wrap scroll+view x20338586 µs17266 µs19.6x
decoder plain 100000 bytes6445149 µs3686 µs1748.5x

Startup (first visible frame)

ModeMedian first visible
JIT source553 ms
Kernel snapshot158 ms
AOT executable11 ms
Microbench ratios are host-specific. Clone the repo and run make bench-hotpath on your machine rather than treating any published number as a guarantee.

For the full audit vs e00de92, see docs/performance.md.

Related