Skip to content

benchmarks: add end-to-end scroll and caret movement suites#52

Merged
tig merged 1 commit into
developfrom
benchmarks/scrolling-baseline
May 11, 2026
Merged

benchmarks: add end-to-end scroll and caret movement suites#52
tig merged 1 commit into
developfrom
benchmarks/scrolling-baseline

Conversation

@tig

@tig tig commented May 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds EndToEndScrollBenchmarks and CaretMovementBenchmarks — full input→render pipeline benchmarks using real key injection, layout, and draw cycles.
  • Adds EditorHarness — a lightweight sync wrapper around Application.Create + ANSI driver + Editor for BenchmarkDotNet.

These complement the isolated-layer benchmarks from #50 by measuring what the user actually experiences: keypress → caret move → viewport scroll → full redraw.

EndToEndScrollBenchmarks

Benchmark What it does
Arrow ↓ to bottom CursorDown from line 0 until caret reaches last line
Arrow ↑ to top CursorUp from last line back to line 0
Arrow → to end CursorRight char-by-char until caret reaches document end (100-line subset)
Arrow ← to start CursorLeft char-by-char back to offset 0 (100-line subset)
PageDown to bottom PageDown until caret reaches last line
PageUp to top PageUp from bottom back to line 0

CaretMovementBenchmarks

Benchmark What it does
Caret ↓ with scroll counting Arrow down through 1K lines, counting viewport scrolls at boundary
Caret ↑ with scroll counting Arrow up from bottom, counting viewport scrolls
Caret → horizontal scroll Right through 500-char line in 40-col viewport, counting horizontal scrolls
Caret ← horizontal scroll Left from end of 500-char line, counting horizontal scrolls
Home/End oscillation 500 alternating Home/End on a long line — worst-case horizontal viewport churn
Ctrl+Home/End oscillation 100 alternating Ctrl+Home/End — worst-case vertical viewport churn

Sample results (ShortRun, Apple M4 Max, 1K-line doc)

Benchmark Mean Allocated
Caret ↓ (1K lines) 1,305 ms 5.2 GB
Caret ↑ (1K lines) 1,320 ms 5.2 GB
Caret → horizontal 129 ms 570 MB
Caret ← horizontal 132 ms 571 MB
Home/End oscillation 85 ms 363 MB
Ctrl+Home/End oscillation 130 ms 533 MB

The vertical scroll numbers (1.3s for 1K lines, 5.2 GB allocated) make the case for visual-line caching (#49) very clearly — each of the 1K arrow-down steps rebuilds all 24 visible lines from scratch.

Running

dotnet run --project benchmarks/Terminal.Gui.Editor.Benchmarks -c Release -- --filter "*EndToEnd*"
dotnet run --project benchmarks/Terminal.Gui.Editor.Benchmarks -c Release -- --filter "*CaretMovement*"

Test plan

  • dotnet build Terminal.Gui.Text.slnx succeeds
  • dotnet format --verify-no-changes passes
  • CaretMovementBenchmarks dry run completes successfully
  • EndToEndScrollBenchmarks dry run in progress (arrow ↓/↑ at 500 and 5K lines validated)
  • All existing tests pass (53 editor + 85 integration)

🤖 Generated with Claude Code

Adds two new benchmark classes that exercise the full input→render
pipeline via real key injection, layout, and draw cycles:

- EndToEndScrollBenchmarks: arrow ↓/↑/→/← and PageDown/PageUp from
  one end of the document to the other, rendering after every keypress.
  Each benchmark checks viewport/caret state to detect when the
  boundary is reached.
- CaretMovementBenchmarks: caret movement with scroll-event counting
  (detects each viewport shift at edges), plus Home/End and
  Ctrl+Home/End oscillation stress tests.

Also adds EditorHarness — a lightweight sync wrapper around
Application.Create + ANSI driver + Editor that BenchmarkDotNet can
manage without async disposal.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tig
tig merged commit 36281b9 into develop May 11, 2026
6 checks passed
@tig
tig deleted the benchmarks/scrolling-baseline branch May 11, 2026 12:54
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