mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-20 13:30:46 +02:00
admin: step down latency units instead of rounding to 0 ms
SeaweedFS latency quantiles are frequently sub-millisecond, so a fixed millisecond format rendered every axis tick as '0 ms'. Use µs below 1 ms and add decimals below 10 ms.
This commit is contained in:
@@ -186,10 +186,20 @@ func FormatChartValue(v float64, unit string) string {
|
||||
case UnitBytesPS:
|
||||
return formatChartBytes(v) + "/s"
|
||||
case UnitSeconds:
|
||||
if v < 1 {
|
||||
return fmt.Sprintf("%.0f ms", v*1000)
|
||||
// Latency quantiles are often sub-millisecond, so step down the unit
|
||||
// rather than rounding everything to "0 ms".
|
||||
switch {
|
||||
case v == 0:
|
||||
return "0"
|
||||
case v < 0.001:
|
||||
return fmt.Sprintf("%.0f µs", v*1e6)
|
||||
case v < 0.01:
|
||||
return fmt.Sprintf("%.2f ms", v*1000)
|
||||
case v < 1:
|
||||
return fmt.Sprintf("%.1f ms", v*1000)
|
||||
default:
|
||||
return fmt.Sprintf("%.2f s", v)
|
||||
}
|
||||
return fmt.Sprintf("%.2f s", v)
|
||||
case UnitPercent:
|
||||
return fmt.Sprintf("%.0f%%", v)
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user