diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-23 20:16:15 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-23 20:16:15 +0300 |
| commit | f12756eecf2ea791ad894cc63380ed78f22f8797 (patch) | |
| tree | e506ace88b6db5ba7371d2b7f421fe480ddf45f0 /internal/tui | |
| parent | 4e67c348ef1dc2c0d08f3e90c2affb555b205d0e (diff) | |
9c move Non-IO grouping policy from core stats/types into dashboard
Snapshot.NonIOFamilies, Snapshot.NonIOFamiliesCount, and
types.IsNonIOSyscallFamily encoded a TUI tab concept in core packages.
Move this filtering into internal/tui/dashboard/nonio.go as unexported
helpers so the dashboard owns its own grouping policy and
Snapshot.Families remains the neutral core API.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Diffstat (limited to 'internal/tui')
| -rw-r--r-- | internal/tui/dashboard/model.go | 2 | ||||
| -rw-r--r-- | internal/tui/dashboard/nonio.go | 37 | ||||
| -rw-r--r-- | internal/tui/dashboard/nonio_test.go | 37 |
3 files changed, 74 insertions, 2 deletions
diff --git a/internal/tui/dashboard/model.go b/internal/tui/dashboard/model.go index 1f479c7..fa36453 100644 --- a/internal/tui/dashboard/model.go +++ b/internal/tui/dashboard/model.go @@ -884,7 +884,7 @@ func (m Model) maxSyscallsRows() int { } func (m Model) maxNonIORows() int { - return m.snapshotOrZero().NonIOFamiliesCount() + return nonIOFamiliesCount(m.snapshotOrZero().Families()) } func (m Model) maxFilesRows() int { diff --git a/internal/tui/dashboard/nonio.go b/internal/tui/dashboard/nonio.go index aef63f4..42069a2 100644 --- a/internal/tui/dashboard/nonio.go +++ b/internal/tui/dashboard/nonio.go @@ -6,6 +6,7 @@ import ( "ior/internal/statsengine" common "ior/internal/tui/common" + "ior/internal/types" ) func renderNonIO(snap *statsengine.Snapshot, width, height int) string { @@ -17,7 +18,7 @@ func renderNonIOWithOffset(snap *statsengine.Snapshot, width, height, offset, se return "Non-IO: waiting for stats..." } - rowsData := snap.NonIOFamilies() + rowsData := nonIOFamilies(snap.Families()) columns, rows := nonIOTableData(rowsData, width) if len(rows) == 0 { return "Non-IO: no data" @@ -97,3 +98,37 @@ func nonIORowsCompact(families []statsengine.FamilySnapshot) [][]string { } return rows } + +// isFileSyscallFamily reports whether family belongs to file-system/fd views. +// This is a dashboard presentation concept: the Non-IO tab excludes FS families. +func isFileSyscallFamily(family types.SyscallFamily) bool { + return family == types.FamilyFS +} + +// isNonIOSyscallFamily reports whether family should appear in the Non-IO tab. +// This is a dashboard grouping policy kept out of the core stats/types packages. +func isNonIOSyscallFamily(family types.SyscallFamily) bool { + return family != "" && !isFileSyscallFamily(family) +} + +// nonIOFamilies filters family snapshot rows to those outside the FS family. +func nonIOFamilies(all []statsengine.FamilySnapshot) []statsengine.FamilySnapshot { + rows := make([]statsengine.FamilySnapshot, 0, len(all)) + for _, row := range all { + if isNonIOSyscallFamily(row.Family) { + rows = append(rows, row) + } + } + return rows +} + +// nonIOFamiliesCount returns the number of non-FS family rows. +func nonIOFamiliesCount(all []statsengine.FamilySnapshot) int { + count := 0 + for _, row := range all { + if isNonIOSyscallFamily(row.Family) { + count++ + } + } + return count +} diff --git a/internal/tui/dashboard/nonio_test.go b/internal/tui/dashboard/nonio_test.go index 5fabc76..0b5fc25 100644 --- a/internal/tui/dashboard/nonio_test.go +++ b/internal/tui/dashboard/nonio_test.go @@ -35,3 +35,40 @@ func TestRenderNonIOIncludesExpectedFamilyRows(t *testing.T) { t.Fatalf("non-io table should exclude FS rows:\n%s", out) } } + +func TestNonIOFamiliesFiltering(t *testing.T) { + all := []statsengine.FamilySnapshot{ + {Family: types.FamilyFS, Name: "FS"}, + {Family: types.FamilyPolling, Name: "Polling"}, + {Family: types.FamilyProcess, Name: "Process"}, + } + + rows := nonIOFamilies(all) + if len(rows) != 2 { + t.Fatalf("nonIOFamilies len = %d, want 2", len(rows)) + } + if rows[0].Family == types.FamilyFS || rows[1].Family == types.FamilyFS { + t.Fatalf("nonIOFamilies included FS: %+v", rows) + } + if got := nonIOFamiliesCount(all); got != 2 { + t.Fatalf("nonIOFamiliesCount = %d, want 2", got) + } +} + +func TestIsNonIOSyscallFamily(t *testing.T) { + tests := []struct { + family types.SyscallFamily + want bool + }{ + {types.FamilyFS, false}, + {types.FamilyPolling, true}, + {types.FamilyProcess, true}, + {types.FamilyNetwork, true}, + {"", false}, + } + for _, tt := range tests { + if got := isNonIOSyscallFamily(tt.family); got != tt.want { + t.Errorf("isNonIOSyscallFamily(%q) = %v, want %v", tt.family, got, tt.want) + } + } +} |
