Skip to content

Commit

Permalink
show the final mb/s after finish
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Nov 17, 2019
1 parent fd48575 commit ae2e9ce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.12
require (
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213
github.com/mattn/go-isatty v0.0.8 // indirect
github.com/schollz/progressbar/v2 v2.13.2
github.com/schollz/progressbar/v2 v2.14.0
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed // indirect
)
4 changes: 2 additions & 2 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2Em
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/schollz/progressbar/v2 v2.13.2 h1:3L9bP5KQOGEnFP8P5V8dz+U0yo5I29iY5Oa9s9EAwn0=
github.com/schollz/progressbar/v2 v2.13.2/go.mod h1:6YZjqdthH6SCZKv2rqGryrxPtfmRB/DWZxSMfCXPyD8=
github.com/schollz/progressbar/v2 v2.14.0 h1:vo7bdkI9E4/CIk9DnL5uVIaybLQiVtiCC2vO+u9j5IM=
github.com/schollz/progressbar/v2 v2.14.0/go.mod h1:6YZjqdthH6SCZKv2rqGryrxPtfmRB/DWZxSMfCXPyD8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ require (
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
github.com/stretchr/testify v1.3.0
)

go 1.13
5 changes: 5 additions & 0 deletions progressbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@ func renderProgressBar(c config, s state) (int, error) {

// add on bytes string if max bytes option was set
kbPerSecond := averageRate / float64(c.max) * float64(c.maxBytes) / 1000.0
if s.finished {
// if finished then show the overall time taken
kbPerSecond = float64(c.maxBytes) / 1000.0 / time.Since(s.startTime).Seconds()
}

if kbPerSecond > 1000.0 {
bytesString = fmt.Sprintf("(%2.1f MB/s)", kbPerSecond/1000.0)
} else if kbPerSecond > 0 {
Expand Down

0 comments on commit ae2e9ce

Please sign in to comment.