Codebase list golang-github-vbauerster-mpb / 392f45a
Refactoring: satrtBlock to sbEta Vladimir Bauer 8 years ago
3 changed file(s) with 12 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
3838
3939 total := 100
4040 name := "Single Bar:"
41 startBlock := make(chan time.Time)
41 sbEta := make(chan time.Time)
4242 // adding a single bar
4343 bar := p.AddBar(int64(total),
4444 mpb.PrependDecorators(
4747 // replace ETA decorator with "done" message, OnComplete event
4848 decor.OnComplete(
4949 // ETA decorator with default eta age, and width reservation of 4
50 decor.ETA(decor.ET_STYLE_GO, 0, startBlock, decor.WC{W: 4}), "done",
50 decor.ETA(decor.ET_STYLE_GO, 0, sbEta, decor.WC{W: 4}), "done",
5151 ),
5252 ),
5353 mpb.AppendDecorators(decor.Percentage()),
5757 max := 100 * time.Millisecond
5858 for i := 0; i < total; i++ {
5959 // update start block time, required for ETA calculation
60 startBlock <- time.Now()
60 sbEta <- time.Now()
6161 time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
6262 // increment by 1 (there is bar.IncrBy(int) method, if needed)
6363 bar.Increment()
7575
7676 for i := 0; i < numBars; i++ {
7777 name := fmt.Sprintf("Bar#%d:", i)
78 startBlock := make(chan time.Time)
78 sbEta := make(chan time.Time)
7979 bar := p.AddBar(int64(total),
8080 mpb.PrependDecorators(
8181 // display our name with one space on the right
8787 // replace ETA decorator with "done" message, OnComplete event
8888 decor.OnComplete(
8989 // ETA decorator with default eta age, and width reservation of 3
90 decor.ETA(decor.ET_STYLE_GO, 0, startBlock, decor.WC{W: 3}), "done",
90 decor.ETA(decor.ET_STYLE_GO, 0, sbEta, decor.WC{W: 3}), "done",
9191 ),
9292 ),
9393 )
9696 defer wg.Done()
9797 max := 100 * time.Millisecond
9898 for i := 0; i < total; i++ {
99 startBlock <- time.Now()
99 sbEta <- time.Now()
100100 time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
101101 bar.Increment()
102102 }
2121
2222 for i := 0; i < numBars; i++ {
2323 name := fmt.Sprintf("Bar#%d:", i)
24 startBlock := make(chan time.Time)
24 sbEta := make(chan time.Time)
2525 bar := p.AddBar(int64(total),
2626 mpb.PrependDecorators(
2727 // display our name with one space on the right
3333 // replace ETA decorator with "done" message, OnComplete event
3434 decor.OnComplete(
3535 // ETA decorator with default eta age, and width reservation of 3
36 decor.ETA(decor.ET_STYLE_GO, 0, startBlock, decor.WC{W: 3}), "done",
36 decor.ETA(decor.ET_STYLE_GO, 0, sbEta, decor.WC{W: 3}), "done",
3737 ),
3838 ),
3939 )
4242 defer wg.Done()
4343 max := 100 * time.Millisecond
4444 for i := 0; i < total; i++ {
45 startBlock <- time.Now()
45 sbEta <- time.Now()
4646 time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
4747 bar.Increment()
4848 }
1919
2020 total := 100
2121 name := "Single Bar:"
22 startBlock := make(chan time.Time)
22 sbEta := make(chan time.Time)
2323 // adding a single bar
2424 bar := p.AddBar(int64(total),
2525 mpb.PrependDecorators(
2828 // replace ETA decorator with "done" message, OnComplete event
2929 decor.OnComplete(
3030 // ETA decorator with default eta age, and width reservation of 4
31 decor.ETA(decor.ET_STYLE_GO, 0, startBlock, decor.WC{W: 4}), "done",
31 decor.ETA(decor.ET_STYLE_GO, 0, sbEta, decor.WC{W: 4}), "done",
3232 ),
3333 ),
3434 mpb.AppendDecorators(decor.Percentage()),
3838 max := 100 * time.Millisecond
3939 for i := 0; i < total; i++ {
4040 // update start block time, required for ETA calculation
41 startBlock <- time.Now()
41 sbEta <- time.Now()
4242 time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
4343 // increment by 1 (there is bar.IncrBy(int) method, if needed)
4444 bar.Increment()