2017-12-16 11:54:21 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
// Should be enough for wide-screen terminals
|
|
|
|
const HistoryLimit = 1024
|
|
|
|
|
|
|
|
// Data holds actual data values, being a buffer for
|
|
|
|
// UI widges and responsible for flushing/updating/deleting
|
|
|
|
// old values.
|
|
|
|
type Data struct {
|
|
|
|
cpu *CircularBuffer
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewData inits new data object.
|
|
|
|
func NewData() *Data {
|
|
|
|
return &Data{
|
|
|
|
cpu: NewCircularBuffer(HistoryLimit),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-16 12:00:33 +00:00
|
|
|
// AddCPUValues inserts new CPU measurements into data.
|
2017-12-16 11:54:21 +00:00
|
|
|
func (d *Data) AddCPUValue(value float64) {
|
|
|
|
d.cpu.Add(value)
|
|
|
|
}
|
|
|
|
|
2017-12-16 12:00:33 +00:00
|
|
|
// CPU returns CPU values.
|
|
|
|
func (d *Data) CPU() []float64 {
|
2017-12-16 11:54:21 +00:00
|
|
|
return d.cpu.Data()
|
|
|
|
}
|