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 <noreply@anthropic.com>
This commit is contained in:
Stefan Haller
2026-11-12 11:27:59 +01:00
co-authored by Claude Opus 5.5
parent e2418047df
commit cccd088895
+15
View File
@@ -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)
}
}