mirror of
https://github.com/bolucat/Archive.git
synced 2025-12-24 13:28:37 +08:00
Update On Wed Jul 3 20:29:14 CEST 2024
This commit is contained in:
@@ -14,3 +14,13 @@ func PrettyByteSize(bf float64) string {
|
||||
}
|
||||
return fmt.Sprintf(" %.1fYiB ", bf)
|
||||
}
|
||||
|
||||
func PrettyBitRate(bps float64) string {
|
||||
for _, unit := range []string{"bps", "Kbps", "Mbps", "Gbps", "Tbps", "Pbps", "Ebps", "Zbps"} {
|
||||
if math.Abs(bps) < 1000.0 {
|
||||
return fmt.Sprintf(" %3.1f %s ", bps, unit)
|
||||
}
|
||||
bps /= 1000.0
|
||||
}
|
||||
return fmt.Sprintf(" %.1f Ybps ", bps)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user