Skip to content

feat(tui): let the console driver be chosen, and measure what a repaint costs - #3

Merged
M0LTE merged 1 commit into
mainfrom
feat/tui-driver-choice
Aug 21, 2026
Merged

feat(tui): let the console driver be chosen, and measure what a repaint costs#3
M0LTE merged 1 commit into
mainfrom
feat/tui-driver-choice

Conversation

@M0LTE

@M0LTE M0LTE commented Aug 21, 2026

Copy link
Copy Markdown
Owner

You are running the win-x64 binary locally on Windows, in both PowerShell and cmd, and typing into the editor is still 1-2 seconds a character. That rules out the link, which was my previous theory, and leaves the repaint itself: Terminal.Gui redraws the whole screen for every inserted character, and what that costs depends entirely on how the driver hands it to the console. Per-call console cost on Windows is far higher than on a Unix pty, and which of Terminal.Gui's three drivers is quickest there is not something I can settle from a Linux box.

So this makes it measurable and changeable on the machine that has the problem.

tait-codeplug tui --driver list                what this platform offers
tait-codeplug tui --bench                      time one repaint on the default driver
tait-codeplug tui --bench --driver ansi
tait-codeplug tui --driver ansi radio.m8p      use the quickest one

--bench prints the screen size, the driver, and a median over 30 repaints. A repaint is exactly what one typed character costs, so that number is the thing you are feeling. Under about 30ms is instant; a few hundred milliseconds is the sluggishness.

For scale, this machine (Linux, tmux, 100x30): ansi 17.7 ms, dotnet 8.5 ms. Both instant. If windows comes out in the hundreds on your console, that is the entire complaint and the fix is a different driver.

One implementation note worth keeping: the benchmark has to run inside the application loop. Outside it the driver is not live, the terminal has not answered the size query yet, and a draw costs nothing because nothing reaches the console - the first version cheerfully reported 0.0 ms against a 0x0 screen.

86 tests, up from 77: the argument handling (default stays the library's choice, names are case-insensitive, a typo lists the options rather than silently falling back).

Merging this wants a v0.8.0 tag; the CHANGELOG section is written.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FkDFej82QnbjMJYFcwYyAZ

…nt costs

Typing into the editor is slow on Windows with the tool running locally, which
rules out the link and leaves the repaint itself. Terminal.Gui redraws the whole
screen for every inserted character, and what that costs depends entirely on how
the driver hands it to the console - a cost that is far higher per call on
Windows than on a Unix pty, and one that cannot be measured from here.

So make it measurable and changeable where it matters:

  tait-codeplug tui --driver list       what this platform offers
  tait-codeplug tui --bench             time one repaint on the default driver
  tait-codeplug tui --bench --driver ansi
  tait-codeplug tui --driver ansi radio.m8p

Terminal.Gui ships three drivers (windows, ansi, dotnet) and picks one per
platform. The pick is now overridable, and --bench reports the screen size, the
driver and a median over 30 repaints, so the quickest one for a given console can
be found in about a minute rather than guessed at.

The benchmark has to run inside the application loop: outside it the driver is
not live, the terminal has not answered the size query, and a draw costs nothing
because nothing reaches the console. The first version measured 0.0 ms against a
0x0 screen, which is exactly the sort of number that looks like good news.

For scale, on Linux in tmux at 100x30: ansi 17.7 ms, dotnet 8.5 ms per repaint.
Both feel instant. If the Windows driver comes out in the hundreds, that is the
whole complaint, and switching driver is the fix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FkDFej82QnbjMJYFcwYyAZ
@M0LTE
M0LTE merged commit d1fb298 into main Aug 21, 2026
1 check passed
@M0LTE
M0LTE deleted the feat/tui-driver-choice branch August 21, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant