diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-06 15:21:01 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-06 15:21:01 +0200 |
| commit | 4ff17c30120d657b966f8a55188ba167dc875e64 (patch) | |
| tree | 62737caf6b8e7411c2437dd995d3de5ce6aeca99 /internal/tui/flamegraph/model.go | |
| parent | 1530bf2856bbb32a6e0457596b55c07f3836a0ec (diff) | |
feat(tui): add flamegraph bytes metric toggle
Diffstat (limited to 'internal/tui/flamegraph/model.go')
| -rw-r--r-- | internal/tui/flamegraph/model.go | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/internal/tui/flamegraph/model.go b/internal/tui/flamegraph/model.go index 2b974fe..c4973fb 100644 --- a/internal/tui/flamegraph/model.go +++ b/internal/tui/flamegraph/model.go @@ -88,6 +88,7 @@ type Model struct { fieldPresets [][]string fieldIndex int + countField string animation AnimationState animating bool @@ -132,11 +133,13 @@ func NewModel(liveTrie *coreflamegraph.LiveTrie) Model { {"pid", "tracepoint", "path"}, {"comm", "path", "tracepoint"}, }, - isDark: true, - keys: defaultFlameKeyMap(), - animation: NewAnimationState(30, 6.0, 1.0), + isDark: true, + keys: defaultFlameKeyMap(), + animation: NewAnimationState(30, 6.0, 1.0), + countField: "count", } m.syncFieldPresetToTrie() + m.syncCountFieldToTrie() return m } @@ -213,6 +216,9 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case isCycleOrderKey(msg): handled = true m.cycleFieldOrder() + case isCycleMetricKey(msg): + handled = true + m.toggleCountField() case isHelpToggleKey(msg): handled = true m.toggleHelp() @@ -265,6 +271,7 @@ func (m Model) ConsumesKey(msg tea.KeyPressMsg) bool { isPauseKey(msg), isResetBaselineKey(msg), isCycleOrderKey(msg), + isCycleMetricKey(msg), isHelpToggleKey(msg): return true case isZoomInKey(msg, m.keys), @@ -293,7 +300,7 @@ func (m Model) View() tea.View { renderHeight = 3 } - content := RenderTerminalView(m.frames, m.width, renderHeight, m.selectedIdx, m.subtreeSet, m.matchIndices, m.filterVisible, m.globalTotal, m.isDark, m.searchActive, m.searchQuery) + content := RenderTerminalView(m.frames, m.width, renderHeight, m.selectedIdx, m.subtreeSet, m.matchIndices, m.filterVisible, m.globalTotal, m.countFieldLabel(), m.isDark, m.searchActive, m.searchQuery) content = replaceHeaderLine(content, m.toolbarLine()) if m.searchActive { content = replaceFooterLine(content, m.searchFooter()) @@ -312,6 +319,7 @@ func (m Model) View() tea.View { func (m *Model) SetLiveTrie(liveTrie *coreflamegraph.LiveTrie) { m.liveTrie = liveTrie m.syncFieldPresetToTrie() + m.syncCountFieldToTrie() m.lastVersion = 0 m.snapshot = nil m.globalTotal = 0 @@ -349,6 +357,18 @@ func (m *Model) syncFieldPresetToTrie() { m.fieldIndex = 0 } +func (m *Model) syncCountFieldToTrie() { + if m.liveTrie == nil { + m.countField = "count" + return + } + field := strings.TrimSpace(m.liveTrie.CountField()) + if field == "" { + field = "count" + } + m.countField = field +} + // RefreshFromLiveTrie loads a new snapshot when the source version changes. func (m *Model) RefreshFromLiveTrie() bool { if m.liveTrie == nil { @@ -881,6 +901,9 @@ func isResetBaselineKey(msg tea.KeyPressMsg) bool { return keyString(msg) == "r" } func isCycleOrderKey(msg tea.KeyPressMsg) bool { return keyString(msg) == "o" } +func isCycleMetricKey(msg tea.KeyPressMsg) bool { + return keyString(msg) == "b" +} func isHelpToggleKey(msg tea.KeyPressMsg) bool { return keyString(msg) == "?" } func isZoomInKey(msg tea.KeyPressMsg, keys flameKeyMap) bool { |
