summaryrefslogtreecommitdiff
path: root/internal/tui/flamegraph
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-27 08:21:33 +0300
committerPaul Buetow <paul@buetow.org>2026-05-27 08:21:33 +0300
commit44fa9635c64477fe2e5a1205dd68e82c7c6b6ce9 (patch)
tree199096ffbbfce56dffb8b4ada609a4822b5099ff /internal/tui/flamegraph
parent4365542fc8c08f7ce11040fa62a94a78fba1c2e2 (diff)
flamegraph: show selected height metric in status line (zo)
Diffstat (limited to 'internal/tui/flamegraph')
-rw-r--r--internal/tui/flamegraph/controls.go12
-rw-r--r--internal/tui/flamegraph/model_test.go30
2 files changed, 41 insertions, 1 deletions
diff --git a/internal/tui/flamegraph/controls.go b/internal/tui/flamegraph/controls.go
index c9e5484..7eee102 100644
--- a/internal/tui/flamegraph/controls.go
+++ b/internal/tui/flamegraph/controls.go
@@ -156,7 +156,7 @@ func (m Model) selectionStatusLine() string {
mode = "PAUSED"
}
heightLabel := ""
- if m.heightField != "" {
+ if m.heightMetricActive() {
heightLabel = " | height:" + m.heightFieldLabel()
}
if len(m.frames) == 0 {
@@ -168,6 +168,16 @@ func (m Model) selectionStatusLine() string {
selIdx = 0
}
frame := m.frames[selIdx]
+ if m.heightMetricActive() {
+ maxHeightTotal := uint64(0)
+ for i := range m.frames {
+ if m.frames[i].HeightTotal > maxHeightTotal {
+ maxHeightTotal = m.frames[i].HeightTotal
+ }
+ }
+ heightShare := percentOfTotal(frame.HeightTotal, maxHeightTotal)
+ heightLabel = fmt.Sprintf(" | height(%s)=%d (%.1f%% of max)", m.heightFieldLabel(), frame.HeightTotal, heightShare)
+ }
systemShare := frame.Percent
if m.globalTotal > 0 {
systemShare = percentOfTotal(frame.Total, m.globalTotal)
diff --git a/internal/tui/flamegraph/model_test.go b/internal/tui/flamegraph/model_test.go
index c5da062..80a86bb 100644
--- a/internal/tui/flamegraph/model_test.go
+++ b/internal/tui/flamegraph/model_test.go
@@ -890,6 +890,36 @@ func TestViewSelectionStatusUsesBytesLabelInBytesMode(t *testing.T) {
}
}
+func TestSelectionStatusLineIncludesSelectedHeightValueAndMaxShare(t *testing.T) {
+ m := NewModel(nil)
+ m.width = 220
+ m.height = 20
+ m.heightField = "duration"
+ m.frames = []tuiFrame{
+ {Name: "root", Depth: 0, Col: 0, Row: 0, Width: 120, Total: 100, Percent: 100, Path: "root", HeightTotal: 200},
+ {Name: "child", Depth: 1, Col: 0, Row: 1, Width: 60, Total: 40, Percent: 40, Path: "root" + pathSeparator + "child", HeightTotal: 50},
+ }
+ m.selectedIdx = 1
+ m.globalTotal = 100
+
+ line := m.selectionStatusLine()
+ if !strings.Contains(line, "height(duration)=50 (25.0% of max)") {
+ t.Fatalf("expected selected height metric fragment, got %q", line)
+ }
+}
+
+func TestSelectionStatusLineUsesHeightLabelWithoutSelectedValueWhenNoSelection(t *testing.T) {
+ m := NewModel(nil)
+ m.width = 220
+ m.height = 20
+ m.heightField = "duration"
+
+ line := m.selectionStatusLine()
+ if !strings.Contains(line, "height:duration") {
+ t.Fatalf("expected height field label without selected value when no frames, got %q", line)
+ }
+}
+
func TestViewFitsViewportHeightAndKeepsSearchFooterVisible(t *testing.T) {
m := NewModel(nil)
m.width = 100