Pause spinner ticks when not refreshing.
All checks were successful
Build & Test / Main (push) Successful in 59s
All checks were successful
Build & Test / Main (push) Successful in 59s
Also, add a quick-and-dirty model for displaying basic performance stats, currently just the number of calls to the root Update() and View() methods.
This commit is contained in:
42
tui/perf/perf.go
Normal file
42
tui/perf/perf.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package perf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync/atomic"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
updates *atomic.Int64
|
||||
views *atomic.Int64
|
||||
}
|
||||
|
||||
func New() (m Model) {
|
||||
m.updates = new(atomic.Int64)
|
||||
m.views = new(atomic.Int64)
|
||||
return
|
||||
}
|
||||
|
||||
func (m Model) Init() tea.Cmd {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m Model) View() string {
|
||||
updates := m.updates.Load()
|
||||
views := m.views.Load()
|
||||
s := fmt.Sprintf("updates: %d\tviews: %d", updates, views)
|
||||
return s
|
||||
}
|
||||
|
||||
func (m Model) AddUpdate() {
|
||||
m.updates.Add(1)
|
||||
}
|
||||
|
||||
func (m Model) AddView() {
|
||||
m.views.Add(1)
|
||||
}
|
Reference in New Issue
Block a user