forked from vbauerster/mpb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbarbench_test.go
43 lines (37 loc) · 936 Bytes
/
barbench_test.go
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/mikewiacek/mpb/decor"
)
func BenchmarkIncrSingleBar(b *testing.B) {
p := New(WithOutput(ioutil.Discard))
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))
bar := p.AddBar(int64(b.N))
for !bar.Completed() {
bar.Increment()
}
}
func BenchmarkIncrSingleBarWithNameDecorator(b *testing.B) {
p := New(WithOutput(ioutil.Discard))
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))
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()
}
}