summaryrefslogtreecommitdiff
path: root/internal/tui/dashboard/syscalls.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-24 17:16:17 +0200
committerPaul Buetow <paul@buetow.org>2026-02-24 17:16:17 +0200
commit2ae0b33c9f196634eaa55bd6997d1feae9147385 (patch)
treeea4e0e705c693e44f29924014431186af635b7e5 /internal/tui/dashboard/syscalls.go
parent92114c3b6bfe8a3d28487fcfb34fd291c573500c (diff)
tui: improve dashboard tab navigation and live updates
Diffstat (limited to 'internal/tui/dashboard/syscalls.go')
-rw-r--r--internal/tui/dashboard/syscalls.go60
1 files changed, 47 insertions, 13 deletions
diff --git a/internal/tui/dashboard/syscalls.go b/internal/tui/dashboard/syscalls.go
index bdaa3a0..23fe37c 100644
--- a/internal/tui/dashboard/syscalls.go
+++ b/internal/tui/dashboard/syscalls.go
@@ -18,11 +18,38 @@ func renderSyscallsWithOffset(snap *statsengine.Snapshot, width, height, offset
return "Syscalls: waiting for stats..."
}
- rows := syscallRows(snap.Syscalls())
+ columns, rows := syscallTableData(snap.Syscalls(), width)
if len(rows) == 0 {
return "Syscalls: no data"
}
+ tbl := table.New(
+ table.WithColumns(columns),
+ table.WithRows(rows),
+ table.WithFocused(true),
+ )
+ tbl.SetHeight(syscallTableHeight(height))
+ tbl.SetWidth(tableWidth(width))
+ cursor := clampOffset(offset, len(rows))
+ tbl.SetCursor(cursor)
+ return tbl.View() + fmt.Sprintf("\nRow %d/%d", cursor+1, len(rows))
+}
+
+func syscallTableData(syscalls []statsengine.SyscallSnapshot, width int) ([]table.Column, []table.Row) {
+ if width < 140 {
+ columns := []table.Column{
+ {Title: "Syscall", Width: 14},
+ {Title: "Count", Width: 6},
+ {Title: "Rate/s", Width: 7},
+ {Title: "Avg", Width: 8},
+ {Title: "p95", Width: 8},
+ {Title: "p99", Width: 8},
+ {Title: "Bytes", Width: 8},
+ {Title: "Errors", Width: 6},
+ }
+ return columns, syscallRowsCompact(syscalls)
+ }
+
columns := []table.Column{
{Title: "Syscall", Width: 16},
{Title: "Count", Width: 8},
@@ -36,20 +63,10 @@ func renderSyscallsWithOffset(snap *statsengine.Snapshot, width, height, offset
{Title: "Bytes", Width: 10},
{Title: "Errors", Width: 8},
}
-
- tbl := table.New(
- table.WithColumns(columns),
- table.WithRows(rows),
- table.WithFocused(true),
- )
- tbl.SetHeight(syscallTableHeight(height))
- tbl.SetWidth(tableWidth(width))
- cursor := clampOffset(offset, len(rows))
- tbl.SetCursor(cursor)
- return tbl.View() + fmt.Sprintf("\nRow %d/%d", cursor+1, len(rows))
+ return columns, syscallRowsFull(syscalls)
}
-func syscallRows(syscalls []statsengine.SyscallSnapshot) []table.Row {
+func syscallRowsFull(syscalls []statsengine.SyscallSnapshot) []table.Row {
rows := make([]table.Row, 0, len(syscalls))
for _, s := range syscalls {
rows = append(rows, table.Row{
@@ -69,6 +86,23 @@ func syscallRows(syscalls []statsengine.SyscallSnapshot) []table.Row {
return rows
}
+func syscallRowsCompact(syscalls []statsengine.SyscallSnapshot) []table.Row {
+ rows := make([]table.Row, 0, len(syscalls))
+ for _, s := range syscalls {
+ rows = append(rows, table.Row{
+ s.Name,
+ strconv.FormatUint(s.Count, 10),
+ fmt.Sprintf("%.1f", s.RatePerSec),
+ formatDurationNs(s.LatencyMeanNs),
+ formatDurationUintNs(s.LatencyP95Ns),
+ formatDurationUintNs(s.LatencyP99Ns),
+ formatBytes(float64(s.Bytes)),
+ strconv.FormatUint(s.Errors, 10),
+ })
+ }
+ return rows
+}
+
func formatDurationUintNs(v uint64) string {
return formatDurationNs(float64(v))
}