removed sparkline

This commit is contained in:
sm
2016-02-25 22:54:18 -08:00
parent 89425716d1
commit c5e9dcd2c6
2 changed files with 0 additions and 119 deletions
-54
View File
@@ -45,15 +45,6 @@ func New(interval time.Duration) (*BPS, error) {
return NewPrecise(interval, 100)
}
// MustNew behaves like New, but panics on error.
func MustNew(interval time.Duration) *BPS {
b, err := New(interval)
if err != nil {
panic(err)
}
return b
}
// NewPrecise behaves like New, but allows the user to specify the temporal
// resolution.
//
@@ -131,51 +122,6 @@ func (b *BPS) HumanRate() string {
return human(uint64(b.Rate())) + "/s"
}
// Sparkline returns a human-friendly sprakline of history
func (b *BPS) Sparkline(count int) string {
if count <= 0 || count > len(b.buckets) {
return "bucket count inappropriate"
}
sparks := []string{"▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"}
line := ""
bucketsPer := len(b.buckets) / count
b.Lock()
defer b.Unlock()
var max int64
var cur int64
// find max
for i := 0; i < len(b.buckets); i++ {
cur += b.buckets[i]
if i%bucketsPer == 0 {
if cur > max {
max = cur
}
cur = 0
}
}
if max == 0 {
for i := 0; i < count; i++ {
line += sparks[0]
}
return line
}
cur = 0
for i := 0; i < len(b.buckets); i++ {
val := b.buckets[(b.timeI+i)%len(b.buckets)]
cur += val
if i%bucketsPer == 0 {
approx := int((float64(cur) / float64(max)) * float64(len(sparks)-1))
line += sparks[approx]
cur = 0
}
}
return line
}
// Close cleans up and shuts down a BPS.
func (b *BPS) Close() {
close(b.quit)