Skip to content

Commit

Permalink
Add FormatBPS, FormatBPSValue
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed May 22, 2018
1 parent f411dbf commit c4c412f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions progress/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ func FormatBytes(i int64) (result string) {
return
}

func FormatBPSValue(bps float64) string {
return fmt.Sprintf("%s / s", FormatBytes(int64(bps)))
}

func FormatBPS(size int64, duration time.Duration) string {
return FormatBPSValue(float64(size) * duration.Seconds())
}

func FormatDuration(d time.Duration) string {
res := ""
if d > time.Hour*24 {
Expand Down

0 comments on commit c4c412f

Please sign in to comment.