Skip to content

Commit

Permalink
show the final it/s too
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Nov 17, 2019
1 parent ae2e9ce commit c08b41b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
6 changes: 3 additions & 3 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.14.0
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed // indirect
github.com/mattn/go-isatty v0.0.10 // indirect
github.com/schollz/progressbar/v2 v2.14.1
golang.org/x/sys v0.0.0-20191115151921-52ab43148777 // indirect
)
15 changes: 7 additions & 8 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 h1:qGQQKEcAR99REcMpsXCp3lJ03zYT1PkRd3kQGPn9GVg=
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=
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.14.0 h1:vo7bdkI9E4/CIk9DnL5uVIaybLQiVtiCC2vO+u9j5IM=
github.com/schollz/progressbar/v2 v2.14.0/go.mod h1:6YZjqdthH6SCZKv2rqGryrxPtfmRB/DWZxSMfCXPyD8=
github.com/schollz/progressbar/v2 v2.14.1 h1:eT4hzP05ZMx9j4aQpZf3SMG/GnUzWZWpn0DoLJJHxyY=
github.com/schollz/progressbar/v2 v2.14.1/go.mod h1:UdPq3prGkfQ7MOzZKlDRpYKcFqEMczbD7YmbPgpzKMI=
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=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed h1:uPxWBzB3+mlnjy9W58qY1j/cjyFjutgw/Vhan2zLy/A=
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191115151921-52ab43148777 h1:wejkGHRTr38uaKRqECZlsCsJ1/TGxIyFbH32x5zUdu4=
golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
8 changes: 3 additions & 5 deletions progressbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ func renderProgressBar(c config, s state) (int, error) {
bytesString := ""

averageRate := average(s.counterLastTenRates)
if len(s.counterLastTenRates) == 0 {
if len(s.counterLastTenRates) == 0 || s.finished {
// if no average samples, or if finished,
// then average rate should be the total rate
averageRate = float64(s.currentNum) / time.Since(s.startTime).Seconds()
}

Expand All @@ -438,10 +440,6 @@ 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)
Expand Down

0 comments on commit c08b41b

Please sign in to comment.