tests upd
Vladimir Bauer
6 years ago
| 9 | 9 |
"time"
|
| 10 | 10 |
"unicode/utf8"
|
| 11 | 11 |
|
| 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"
|
| 14 | 14 |
)
|
| 15 | 15 |
|
| 16 | 16 |
func TestBarCompleted(t *testing.T) {
|
| 3 | 3 |
"io/ioutil"
|
| 4 | 4 |
"testing"
|
| 5 | 5 |
|
| 6 | |
"github.com/vbauerster/mpb/v4/decor"
|
|
6 |
"github.com/vbauerster/mpb/v5/decor"
|
| 7 | 7 |
)
|
| 8 | 8 |
|
| 9 | 9 |
func BenchmarkIncrSingleBar(b *testing.B) {
|
| 3 | 3 |
"sync"
|
| 4 | 4 |
"testing"
|
| 5 | 5 |
|
| 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"
|
| 8 | 8 |
)
|
| 9 | 9 |
|
| 10 | 10 |
func TestNameDecorator(t *testing.T) {
|
| 6 | 6 |
"math/rand"
|
| 7 | 7 |
"time"
|
| 8 | 8 |
|
| 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"
|
| 11 | 11 |
)
|
| 12 | 12 |
|
| 13 | 13 |
func Example() {
|
|
| 34 | 34 |
// simulating some work
|
| 35 | 35 |
max := 100 * time.Millisecond
|
| 36 | 36 |
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
|
| 37 | 39 |
start := time.Now()
|
| 38 | 40 |
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))
|
| 41 | 44 |
}
|
| 42 | 45 |
// wait for our bar to complete and flush
|
| 43 | 46 |
p.Wait()
|
| 8 | 8 |
"testing"
|
| 9 | 9 |
"time"
|
| 10 | 10 |
|
| 11 | |
"github.com/vbauerster/mpb/v4"
|
|
11 |
"github.com/vbauerster/mpb/v5"
|
| 12 | 12 |
)
|
| 13 | 13 |
|
| 14 | 14 |
func init() {
|