Sam Fredrickson
eda4200585
All checks were successful
Build & Test / Main (push) Successful in 1m49s
43 lines
624 B
Go
43 lines
624 B
Go
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(_ 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)
|
|
}
|