Skip to content

Commit

Permalink
Fix a bit more style
Browse files Browse the repository at this point in the history
  • Loading branch information
oerlikon committed Nov 18, 2023
1 parent 371fd69 commit f4d8742
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
github.com/rivo/uniseg v0.4.4
github.com/stretchr/testify v1.8.4
golang.org/x/term v0.13.0
golang.org/x/term v0.14.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8=
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
16 changes: 9 additions & 7 deletions progressbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,14 +474,16 @@ func (p *ProgressBar) add(delta int64) error {
if !p.config.totalRate {
// reset the countdown timer approx every second to take rolling average
p.state.counterNumSinceLast += delta
if t := time.Since(p.state.counterTime).Seconds(); t > 0.5 {
rate := float64(p.state.counterNumSinceLast) / t
p.state.counterLastTenRates = append(p.state.counterLastTenRates, rate)
if len(p.state.counterLastTenRates) > 10 {
p.state.counterLastTenRates = p.state.counterLastTenRates[1:]
if p.state.counterNumSinceLast > 0 {
if t := time.Since(p.state.counterTime).Seconds(); t > 0.5 {
rate := float64(p.state.counterNumSinceLast) / t
p.state.counterLastTenRates = append(p.state.counterLastTenRates, rate)
if len(p.state.counterLastTenRates) > 10 {
p.state.counterLastTenRates = p.state.counterLastTenRates[1:]
}
p.state.counterTime = time.Now()
p.state.counterNumSinceLast = 0
}
p.state.counterTime = time.Now()
p.state.counterNumSinceLast = 0
}
}

Expand Down

0 comments on commit f4d8742

Please sign in to comment.