Skip to content

Commit

Permalink
Merge pull request #1126 from apernet/wip-fix-formatspeed
Browse files Browse the repository at this point in the history
fix: incorrect speed conversion base
  • Loading branch information
tobyxdd authored Jun 16, 2024
2 parents 4c2a905 + a852feb commit c5e7aa3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/cmd/speedtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ func formatSpeed(bytes uint32, duration time.Duration, useBytes bool) string {
speed *= 8
}
unitIndex := 0
for speed > 1024 && unitIndex < len(units)-1 {
speed /= 1024
for speed > 1000 && unitIndex < len(units)-1 {
speed /= 1000
unitIndex++
}
return fmt.Sprintf("%.2f %s", speed, units[unitIndex])
Expand Down
4 changes: 2 additions & 2 deletions core/internal/congestion/bbr/bbr_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,8 @@ func formatSpeed(bw Bandwidth) string {
bwf := float64(bw)
units := []string{"bps", "Kbps", "Mbps", "Gbps"}
unitIndex := 0
for bwf > 1024 && unitIndex < len(units)-1 {
bwf /= 1024
for bwf > 1000 && unitIndex < len(units)-1 {
bwf /= 1000
unitIndex++
}
return fmt.Sprintf("%.2f %s", bwf, units[unitIndex])
Expand Down

0 comments on commit c5e7aa3

Please sign in to comment.