summaryrefslogtreecommitdiff
path: root/internal/tui/flamegraph/renderer.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-13 14:41:18 +0300
committerPaul Buetow <paul@buetow.org>2026-05-13 14:41:18 +0300
commitd392eebe5bd127e1573734321b0cabaad4182d7c (patch)
treee6e0b38ba26110411d80e00b224640c26b8110ae /internal/tui/flamegraph/renderer.go
parentde6b9c4741dea87ce66e0309bac580030490dc30 (diff)
perf: replace string += concatenation with strings.Builder in TUI render hot paths
Swap out ad-hoc += string concatenation in the flamegraph toolbar/status lines, dashboard filter summary, bubble/treemap status lines, eventstream view, processes tab, and probes list for strings.Builder, eliminating redundant allocations on every render tick. Also update dashboard/model_test.go fake SnapshotSource implementations to match the updated interface signature. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/tui/flamegraph/renderer.go')
-rw-r--r--internal/tui/flamegraph/renderer.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/internal/tui/flamegraph/renderer.go b/internal/tui/flamegraph/renderer.go
index 24b99ed..361feb2 100644
--- a/internal/tui/flamegraph/renderer.go
+++ b/internal/tui/flamegraph/renderer.go
@@ -246,14 +246,16 @@ func computeRenderParams(frames []tuiFrame, height int) renderViewParams {
// buildToolbar assembles the top-of-view toolbar string and pads/trims it to
// width. The toolbar is replaced by the caller via replaceHeaderLine.
+// A Builder is used to avoid an extra allocation for the optional truncation suffix.
func buildToolbar(frames []tuiFrame, width int, params renderViewParams) string {
viewPath := compactFramePath(frames[0].Path)
- toolbar := fmt.Sprintf("Flame | view:%s | frames:%d | rows:%d",
- viewPath, params.visibleFrames, params.availableRows)
+ var b strings.Builder
+ b.WriteString(fmt.Sprintf("Flame | view:%s | frames:%d | rows:%d",
+ viewPath, params.visibleFrames, params.availableRows))
if params.truncated {
- toolbar += " | showing deepest levels"
+ b.WriteString(" | showing deepest levels")
}
- return padOrTrim(toolbar, width)
+ return padOrTrim(b.String(), width)
}
// buildFilteredStatus builds the per-selection status line when a search filter