From 92ef33d97a437dce2d7b55f06342de388d95f575 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= <peterke@gmail.com>
Date: Wed, 24 Jun 2015 18:30:00 +0300
Subject: rpc/api, cmd/geth: retrievel all percentiles, add time units

---
 cmd/geth/monitorcmd.go | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

(limited to 'cmd/geth')

diff --git a/cmd/geth/monitorcmd.go b/cmd/geth/monitorcmd.go
index ec0dfb8f2..53eb61a46 100644
--- a/cmd/geth/monitorcmd.go
+++ b/cmd/geth/monitorcmd.go
@@ -76,7 +76,10 @@ func monitor(ctx *cli.Context) {
 
 	termui.UseTheme("helloworld")
 
-	rows := 5
+	rows := len(monitored)
+	if rows > 5 {
+		rows = 5
+	}
 	cols := (len(monitored) + rows - 1) / rows
 	for i := 0; i < rows; i++ {
 		termui.Body.AddRows(termui.NewRow())
@@ -207,8 +210,9 @@ func expandMetrics(metrics map[string]interface{}, path string) []string {
 // updateChart inserts a dataset into a line chart, scaling appropriately as to
 // not display weird labels, also updating the chart label accordingly.
 func updateChart(metric string, data []float64, chart *termui.LineChart) {
-	units := []string{"", "K", "M", "G", "T", "E", "P"}
-	colors := []termui.Attribute{termui.ColorBlue, termui.ColorCyan, termui.ColorGreen, termui.ColorYellow, termui.ColorRed, termui.ColorRed, termui.ColorRed}
+	dataUnits := []string{"", "K", "M", "G", "T", "E"}
+	timeUnits := []string{"ns", "µs", "ms", "s", "ks", "ms"}
+	colors := []termui.Attribute{termui.ColorBlue, termui.ColorCyan, termui.ColorGreen, termui.ColorYellow, termui.ColorRed, termui.ColorRed}
 
 	// Find the maximum value and scale under 1K
 	high := data[0]
@@ -225,7 +229,12 @@ func updateChart(metric string, data []float64, chart *termui.LineChart) {
 	}
 	// Update the chart's label with the scale units
 	chart.Border.Label = metric
-	if unit > 0 {
+
+	units := dataUnits
+	if strings.Contains(metric, "Percentiles") {
+		units = timeUnits
+	}
+	if len(units[unit]) > 0 {
 		chart.Border.Label += " [" + units[unit] + "]"
 	}
 	chart.LineColor = colors[unit]
-- 
cgit v1.2.3