From cccd088895db206013f6b4566b4e62034b37762e Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 9 Nov 2026 17:55:25 +0100 Subject: [PATCH] Add a benchmark for drawing a view with many search matches If a search has many matches, scrolling the view becomes laggy because every draw takes long. Add a benchmark for this, so that later commits can show how much faster they make drawing. Co-Authored-By: Claude Opus 5.5 --- pkg/gocui/search_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/gocui/search_test.go b/pkg/gocui/search_test.go index ba20da9de..f9a137877 100644 --- a/pkg/gocui/search_test.go +++ b/pkg/gocui/search_test.go @@ -56,3 +56,18 @@ func BenchmarkWriteToSearchedView(b *testing.B) { v.GetSearchStatus() } } + +func BenchmarkDrawViewWithManySearchMatches(b *testing.B) { + WithSimulationScreen(b, 102, 42) + v := NewView("name", 0, 0, 101, 41, OutputNormal) + // 44000 matches, as when searching a long log for a single letter. + for i := range 4000 { + fmt.Fprintf(v, "line %d of a branch log, where we searched for every letter e\n", i) + } + v.Search("e", nil) + v.SetOriginY(2000) + + for b.Loop() { + v.draw(true) + } +}