X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=state%2Fstate.go;h=90c3f7dc394150bba5acf3c8162bae5bd1c2d6bd;hb=6befaeecc9554be09177e699544d9573e699f1c8;hp=4df68d259a52cf74d4e0541496038264cb220799;hpb=5b2ab1f1d0e4066b9ed416fc7c829ab75b33870c;p=pstop.git diff --git a/state/state.go b/state/state.go index 4df68d2..90c3f7d 100644 --- a/state/state.go +++ b/state/state.go @@ -75,20 +75,23 @@ func (state *State) Setup(dbh *sql.DB) { // do a fresh collection of data and then update the initial values based on that. func (state *State) ResetDBStatistics() { - // collect all initial values on startup / reset - state.fsbi.Collect(state.dbh) - state.tlwsbt.Collect(state.dbh) - state.tiwsbt.Collect(state.dbh) - - state.UpdateInitialValues() + state.CollectAll() + state.SyncReferenceValues() } -func (state *State) UpdateInitialValues() { +func (state *State) SyncReferenceValues() { start := time.Now() - state.fsbi.UpdateInitialValues() - state.tlwsbt.UpdateInitialValues() - state.tiwsbt.UpdateInitialValues() - lib.Logger.Println("state.UpdateInitialValues() took", time.Duration(time.Since(start)).String()) + state.fsbi.SyncReferenceValues() + state.tlwsbt.SyncReferenceValues() + state.tiwsbt.SyncReferenceValues() + lib.Logger.Println("state.SyncReferenceValues() took", time.Duration(time.Since(start)).String()) +} + +// collect all initial values on startup / reset +func (state *State) CollectAll() { + state.fsbi.Collect(state.dbh) + state.tlwsbt.Collect(state.dbh) + state.tiwsbt.Collect(state.dbh) } // Only collect the data we are looking at. @@ -174,7 +177,7 @@ func (state *State) DisplayNext() { func (state State) displayHeading() { state.displayLine0() - state.displayLine1() + state.displayDescription() } func (state State) displayLine0() { @@ -205,17 +208,19 @@ func (state State) displayLine0() { state.screen.PrintAt(0, 0, top_line) } -func (state State) displayLine1() { +func (state State) displayDescription() { + description := "UNKNOWN" + switch state.show { case showLatency, showOps: - state.screen.PrintAt(0, 1, state.tiwsbt.Description()) + description = state.tiwsbt.Description() case showIO: - state.screen.PrintAt(0, 1, state.fsbi.Description()) + description = state.fsbi.Description() case showLocks: - state.screen.PrintAt(0, 1, state.tlwsbt.Description()) - default: - state.screen.PrintAt(0, 1, "UNKNOWN") + description = state.tlwsbt.Description() } + + state.screen.PrintAt(0, 1, description) } func (state *State) displayOpsOrLatency() { @@ -302,8 +307,6 @@ func (state *State) SetWantRelativeStats(want_relative_stats bool) { state.fsbi.SetWantRelativeStats(want_relative_stats) state.tlwsbt.SetWantRelativeStats(state.want_relative_stats) state.tiwsbt.SetWantRelativeStats(state.want_relative_stats) - - state.Display() } // if there's a better way of doing this do it better ...