Codebase list golang-github-vbauerster-mpb / a82889a
tests upd Vladimir Bauer 6 years ago
5 changed file(s) with 13 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
99 "time"
1010 "unicode/utf8"
1111
12 . "github.com/vbauerster/mpb/v4"
13 "github.com/vbauerster/mpb/v4/decor"
12 . "github.com/vbauerster/mpb/v5"
13 "github.com/vbauerster/mpb/v5/decor"
1414 )
1515
1616 func TestBarCompleted(t *testing.T) {
33 "io/ioutil"
44 "testing"
55
6 "github.com/vbauerster/mpb/v4/decor"
6 "github.com/vbauerster/mpb/v5/decor"
77 )
88
99 func BenchmarkIncrSingleBar(b *testing.B) {
33 "sync"
44 "testing"
55
6 . "github.com/vbauerster/mpb/v4"
7 "github.com/vbauerster/mpb/v4/decor"
6 . "github.com/vbauerster/mpb/v5"
7 "github.com/vbauerster/mpb/v5/decor"
88 )
99
1010 func TestNameDecorator(t *testing.T) {
66 "math/rand"
77 "time"
88
9 "github.com/vbauerster/mpb/v4"
10 "github.com/vbauerster/mpb/v4/decor"
9 "github.com/vbauerster/mpb/v5"
10 "github.com/vbauerster/mpb/v5/decor"
1111 )
1212
1313 func Example() {
3434 // simulating some work
3535 max := 100 * time.Millisecond
3636 for i := 0; i < total; i++ {
37 // start variable is solely for EWMA calculation
38 // EWMA's unit of measure is an iteration's taken time
3739 start := time.Now()
3840 time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
39 // since ewma decorator is used, we need to pass time.Since(start)
40 bar.Increment(time.Since(start))
41 bar.Increment()
42 // we need to call DecoratorEwmaUpdate to fulfill ewma decorator's contract
43 bar.DecoratorEwmaUpdate(time.Since(start))
4144 }
4245 // wait for our bar to complete and flush
4346 p.Wait()
88 "testing"
99 "time"
1010
11 "github.com/vbauerster/mpb/v4"
11 "github.com/vbauerster/mpb/v5"
1212 )
1313
1414 func init() {