// do a fresh collection of data and then update the initial values based on that.
func (state *State) ResetDBStatistics() {
- state.fsbi.Collect(state.dbh)
- state.fsbi.UpdateInitialValues()
+ state.CollectAll()
+ state.SyncReferenceValues()
+}
- state.tlwsbt.Collect(state.dbh)
- state.tlwsbt.UpdateInitialValues()
+func (state *State) SyncReferenceValues() {
+ start := time.Now()
+ 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)
- state.tiwsbt.UpdateInitialValues()
+}
+
+// Only collect the data we are looking at.
+func (state *State) Collect() {
+ start := time.Now()
+
+ switch state.show {
+ case showLatency, showOps:
+ state.tiwsbt.Collect(state.dbh)
+ case showIO:
+ state.fsbi.Collect(state.dbh)
+ case showLocks:
+ state.tlwsbt.Collect(state.dbh)
+ }
+ lib.Logger.Println("state.Collect() took", time.Duration(time.Since(start)).String())
}
func (state State) MySQLVersion() string {
func (state State) displayHeading() {
state.displayLine0()
- state.displayLine1()
+ state.displayDescription()
}
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() {
- state.tiwsbt.Collect(state.dbh)
-
state.screen.PrintAt(0, 2, state.tiwsbt.Headings())
max_rows := state.screen.Height() - 3
// show actual I/O latency values
func (state State) displayIO() {
- state.fsbi.Collect(state.dbh)
-
state.screen.PrintAt(0, 2, state.fsbi.Headings())
// print out the data
}
func (state *State) displayLocks() {
- state.tlwsbt.Collect(state.dbh)
-
state.screen.PrintAt(0, 2, state.tlwsbt.Headings())
// print out the data
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 ...