WithWidth
Vladimir Bauer
6 years ago
| 7 | 7 | ) |
| 8 | 8 | |
| 9 | 9 | func BenchmarkIncrSingleBar(b *testing.B) { |
| 10 | p := New(WithOutput(ioutil.Discard)) | |
| 10 | p := New(WithOutput(ioutil.Discard), WithWidth(80)) | |
| 11 | 11 | bar := p.AddBar(int64(b.N)) |
| 12 | 12 | for i := 0; i < b.N; i++ { |
| 13 | 13 | bar.Increment() |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | func BenchmarkIncrSingleBarWhileIsNotCompleted(b *testing.B) { |
| 18 | p := New(WithOutput(ioutil.Discard)) | |
| 18 | p := New(WithOutput(ioutil.Discard), WithWidth(80)) | |
| 19 | 19 | bar := p.AddBar(int64(b.N)) |
| 20 | 20 | for !bar.Completed() { |
| 21 | 21 | bar.Increment() |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | func BenchmarkIncrSingleBarWithNameDecorator(b *testing.B) { |
| 26 | p := New(WithOutput(ioutil.Discard)) | |
| 26 | p := New(WithOutput(ioutil.Discard), WithWidth(80)) | |
| 27 | 27 | bar := p.AddBar(int64(b.N), PrependDecorators(decor.Name("test"))) |
| 28 | 28 | for i := 0; i < b.N; i++ { |
| 29 | 29 | bar.Increment() |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | func BenchmarkIncrSingleBarWithNameAndEwmaETADecorator(b *testing.B) { |
| 34 | p := New(WithOutput(ioutil.Discard)) | |
| 34 | p := New(WithOutput(ioutil.Discard), WithWidth(80)) | |
| 35 | 35 | bar := p.AddBar(int64(b.N), |
| 36 | 36 | PrependDecorators(decor.Name("test")), |
| 37 | 37 | AppendDecorators(decor.EwmaETA(decor.ET_STYLE_GO, 60)), |