Skip to content

Commit

Permalink
Use mebibytes as heap unit
Browse files Browse the repository at this point in the history
  • Loading branch information
nakabonne committed Nov 9, 2020
1 parent b752d06 commit a9b199a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions diagnoser/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,18 @@ func textsInColumn(texts ...Text) []grid.Element {
// appendStats appends entities as soon as a stats arrives.
// Note that it doesn't redraw the moment stats are appended.
func (g *GUI) appendStats(ctx context.Context) {
const (
// originally based on http://golang.org/doc/progs/eff_bytesize.go
_ = iota
kilobyte uint64 = 1 << (10 * iota)
megabyte
)
var (
cpuUsages = make([]float64, 0)
goroutines = make([]float64, 0)
allocs = make([]float64, 0)
idles = make([]float64, 0)
inuses = make([]float64, 0)

megaByte uint64 = 1000000
)

for {
Expand All @@ -169,9 +173,9 @@ func (g *GUI) appendStats(ctx context.Context) {
}
cpuUsages = append(cpuUsages, stats.CPUUsage)
goroutines = append(goroutines, float64(stats.Goroutines))
allocs = append(allocs, float64(stats.HeapAlloc/megaByte))
idles = append(idles, float64(stats.HeapIdle/megaByte))
inuses = append(inuses, float64(stats.HeapInuse/megaByte))
allocs = append(allocs, float64(stats.HeapAlloc/megabyte))
idles = append(idles, float64(stats.HeapIdle/megabyte))
inuses = append(inuses, float64(stats.HeapInuse/megabyte))

g.widgets.CPUChart.Series("cpu-usage", cpuUsages,
linechart.SeriesCellOpts(cell.FgColor(cell.ColorNumber(87))),
Expand Down

0 comments on commit a9b199a

Please sign in to comment.