diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-25 22:58:40 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-25 22:58:40 +0200 |
| commit | 4c34b9efcd539c819648c927d7e3f53220df8ad2 (patch) | |
| tree | f9de9fd650a2d16316ba2c159990d891c9de5189 /internal/statsengine/engine.go | |
| parent | 67e10f34c92e93343adbd690b3b21e455e863bd3 (diff) | |
Fix stream paused scrolling and apply pending TUI/probe updates
Diffstat (limited to 'internal/statsengine/engine.go')
| -rw-r--r-- | internal/statsengine/engine.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/statsengine/engine.go b/internal/statsengine/engine.go index fd46cc3..1ef58cf 100644 --- a/internal/statsengine/engine.go +++ b/internal/statsengine/engine.go @@ -16,6 +16,7 @@ type Engine struct { now func() time.Time startedAt time.Time + topN int totalSyscalls uint64 totalErrors uint64 @@ -72,6 +73,7 @@ func newEngineWithClock(topN int, now func() time.Time) *Engine { return &Engine{ now: now, startedAt: now(), + topN: topN, syscalls: newSyscallAccumulator(), files: newFileRankerWithConfig(topN), processes: newProcessAccumulatorWithConfig(topN), @@ -83,6 +85,33 @@ func newEngineWithClock(topN int, now func() time.Time) *Engine { } } +// Reset clears all accumulated stats and restarts series baselines. +func (e *Engine) Reset() { + if e == nil { + return + } + + e.mu.Lock() + defer e.mu.Unlock() + + e.startedAt = e.now() + e.totalSyscalls = 0 + e.totalErrors = 0 + e.totalBytes = 0 + e.totalReadBytes = 0 + e.totalWriteBytes = 0 + e.totalLatency = 0 + e.totalGap = 0 + e.syscalls = newSyscallAccumulator() + e.files = newFileRankerWithConfig(e.topN) + e.processes = newProcessAccumulatorWithConfig(e.topN) + e.latencyHist = newHistogram() + e.gapHist = newHistogram() + e.latencySeries = newRingTimeSeries() + e.gapSeries = newRingTimeSeries() + e.throughputSeries = newRingTimeSeries() +} + // Ingest updates all aggregates for one event pair. func (e *Engine) Ingest(pair *event.Pair) { if e == nil || pair == nil { |
