Scale integer counts on the panel like every other figure
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -105,6 +106,16 @@ func scaleSI(v float64) string {
|
|||||||
return fmt.Sprintf("%.2f P", v)
|
return fmt.Sprintf("%.2f P", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The integer counterpart, for whole things counted rather than a rate
|
||||||
|
// measured. Below a thousand the figure is the count itself, since two decimals
|
||||||
|
// on a quantity that cannot have them read as precision that is not there.
|
||||||
|
func scaleCount(v uint64) string {
|
||||||
|
if v < 1000 {
|
||||||
|
return strconv.FormatUint(v, 10)
|
||||||
|
}
|
||||||
|
return scaleSI(float64(v))
|
||||||
|
}
|
||||||
|
|
||||||
// The same shape for time, whose magnitudes are sixties and twenty-fours.
|
// The same shape for time, whose magnitudes are sixties and twenty-fours.
|
||||||
func scaleTime(d time.Duration) string {
|
func scaleTime(d time.Duration) string {
|
||||||
switch {
|
switch {
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ func (d *display) errCounts(x, w, y int, e errs) int {
|
|||||||
n := r.get(e)
|
n := r.get(e)
|
||||||
c := errColor(n)
|
c := errColor(n)
|
||||||
cx, cw, cy := d.chipAt(i, x, w, y, d.countChipH(), c)
|
cx, cw, cy := d.chipAt(i, x, w, y, d.countChipH(), c)
|
||||||
ty := d.centerIn(d.gridB, cx, cw, cy+chipPadY, commas(n), c)
|
ty := d.centerIn(d.gridB, cx, cw, cy+chipPadY, scaleCount(n), c)
|
||||||
d.centerIn(d.grid, cx, cw, ty, r.label, c)
|
d.centerIn(d.grid, cx, cw, ty, r.label, c)
|
||||||
}
|
}
|
||||||
return y + d.countsH()
|
return y + d.countsH()
|
||||||
@@ -343,8 +343,8 @@ func (d *display) render(v view, elapsed time.Duration, cable string) error {
|
|||||||
x, w = d.panel(d.sincePanel, v.since)
|
x, w = d.panel(d.sincePanel, v.since)
|
||||||
d.stats(d.gridB, x, w, d.sinceYs[0], []statCell{
|
d.stats(d.gridB, x, w, d.sinceYs[0], []statCell{
|
||||||
{scaleTime(elapsed), "elapsed", uiFg},
|
{scaleTime(elapsed), "elapsed", uiFg},
|
||||||
{scaleSI(float64(v.rxFrames)), "packets", uiFg},
|
{scaleCount(v.rxFrames), "packets", uiFg},
|
||||||
{scaleSI(float64(v.rxGot)), "bytes", uiFg},
|
{scaleCount(v.rxGot), "bytes", uiFg},
|
||||||
{cable, "m", uiFg},
|
{cable, "m", uiFg},
|
||||||
})
|
})
|
||||||
d.errCounts(x, w, d.sinceYs[1], v.since)
|
d.errCounts(x, w, d.sinceYs[1], v.since)
|
||||||
|
|||||||
Reference in New Issue
Block a user