summaryrefslogtreecommitdiffstats
path: root/dependencies/pkg/mod/github.com/vbauerster/mpb/v6@v6.0.4/barbench_test.go
blob: 76beece1c90db316526ac25b5edda1fc6e018ae4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package mpb

import (
	"io/ioutil"
	"testing"

	"github.com/vbauerster/mpb/v6/decor"
)

func BenchmarkIncrSingleBar(b *testing.B) {
	p := New(WithOutput(ioutil.Discard), WithWidth(80))
	bar := p.AddBar(int64(b.N))
	for i := 0; i < b.N; i++ {
		bar.Increment()
	}
}

func BenchmarkIncrSingleBarWhileIsNotCompleted(b *testing.B) {
	p := New(WithOutput(ioutil.Discard), WithWidth(80))
	bar := p.AddBar(int64(b.N))
	for !bar.Completed() {
		bar.Increment()
	}
}

func BenchmarkIncrSingleBarWithNameDecorator(b *testing.B) {
	p := New(WithOutput(ioutil.Discard), WithWidth(80))
	bar := p.AddBar(int64(b.N), PrependDecorators(decor.Name("test")))
	for i := 0; i < b.N; i++ {
		bar.Increment()
	}
}

func BenchmarkIncrSingleBarWithNameAndEwmaETADecorator(b *testing.B) {
	p := New(WithOutput(ioutil.Discard), WithWidth(80))
	bar := p.AddBar(int64(b.N),
		PrependDecorators(decor.Name("test")),
		AppendDecorators(decor.EwmaETA(decor.ET_STYLE_GO, 60)),
	)
	for i := 0; i < b.N; i++ {
		bar.Increment()
	}
}