use bar.Increment
Vladimir Bauer
6 years ago
| 54 | 54 |
for i := 0; i < total; i++ {
|
| 55 | 55 |
start := time.Now()
|
| 56 | 56 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 57 | |
// ewma based decorators require work duration measurement
|
| 58 | |
bar.IncrBy(1, time.Since(start))
|
|
57 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
58 |
bar.Increment(time.Since(start))
|
| 59 | 59 |
}
|
| 60 | 60 |
// wait for our bar to complete and flush
|
| 61 | 61 |
p.Wait()
|
|
| 94 | 94 |
for i := 0; i < total; i++ {
|
| 95 | 95 |
start := time.Now()
|
| 96 | 96 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 97 | |
// ewma based decorators require work duration measurement
|
| 98 | |
bar.IncrBy(1, time.Since(start))
|
|
97 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
98 |
bar.Increment(time.Since(start))
|
| 99 | 99 |
}
|
| 100 | 100 |
}()
|
| 101 | 101 |
}
|
| 49 | 49 |
for i := 0; i < total; i++ {
|
| 50 | 50 |
start := time.Now()
|
| 51 | 51 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 52 | |
// ewma based decorators require work duration measurement
|
| 53 | |
bar.IncrBy(1, time.Since(start))
|
|
52 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
53 |
bar.Increment(time.Since(start))
|
| 54 | 54 |
}
|
| 55 | 55 |
}()
|
| 56 | 56 |
}
|
| 43 | 43 |
for !bar.Completed() {
|
| 44 | 44 |
start := time.Now()
|
| 45 | 45 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 46 | |
// ewma based decorators require work duration measurement
|
| 47 | |
bar.IncrBy(1, time.Since(start))
|
|
46 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
47 |
bar.Increment(time.Since(start))
|
| 48 | 48 |
}
|
| 49 | 49 |
}()
|
| 50 | 50 |
}
|
| 71 | 71 |
for !b.Completed() {
|
| 72 | 72 |
start := time.Now()
|
| 73 | 73 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 74 | |
// ewma based decorators require work duration measurement
|
|
74 |
// since ewma decorator is used, we need to pass time.Since(start)
|
| 75 | 75 |
b.IncrBy(incrBy, time.Since(start))
|
| 76 | 76 |
}
|
| 77 | 77 |
}
|
| 49 | 49 |
for i := 0; i < total; i++ {
|
| 50 | 50 |
start := time.Now()
|
| 51 | 51 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 52 | |
// ewma based decorators require work duration measurement
|
| 53 | |
bar.IncrBy(1, time.Since(start))
|
|
52 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
53 |
bar.Increment(time.Since(start))
|
| 54 | 54 |
}
|
| 55 | 55 |
}()
|
| 56 | 56 |
}
|
| 50 | 50 |
for i := 0; i < total; i++ {
|
| 51 | 51 |
start := time.Now()
|
| 52 | 52 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 53 | |
// ewma based decorators require work duration measurement
|
| 54 | |
bar.IncrBy(1, time.Since(start))
|
|
53 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
54 |
bar.Increment(time.Since(start))
|
| 55 | 55 |
}
|
| 56 | 56 |
}()
|
| 57 | 57 |
}
|
| 44 | 44 |
for i := 0; i < total; i++ {
|
| 45 | 45 |
start := time.Now()
|
| 46 | 46 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 47 | |
// ewma based decorators require work duration measurement
|
| 48 | |
bar.IncrBy(1, time.Since(start))
|
|
47 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
48 |
bar.Increment(time.Since(start))
|
| 49 | 49 |
}
|
| 50 | 50 |
}()
|
| 51 | 51 |
}
|
| 59 | 59 |
for i := 0; i < total; i++ {
|
| 60 | 60 |
start := time.Now()
|
| 61 | 61 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 62 | |
// ewma based decorators require work duration measurement
|
| 63 | |
bar.IncrBy(1, time.Since(start))
|
|
62 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
63 |
bar.Increment(time.Since(start))
|
| 64 | 64 |
}
|
| 65 | 65 |
}()
|
| 66 | 66 |
}
|
| 40 | 40 |
b.Abort(true)
|
| 41 | 41 |
}
|
| 42 | 42 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 43 | |
// ewma based decorators require work duration measurement
|
| 44 | |
b.IncrBy(1, time.Since(start))
|
|
43 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
44 |
b.Increment(time.Since(start))
|
| 45 | 45 |
}
|
| 46 | 46 |
}()
|
| 47 | 47 |
}
|
| 47 | 47 |
for i := 0; i < total; i++ {
|
| 48 | 48 |
start := time.Now()
|
| 49 | 49 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 50 | |
// ewma based decorators require work duration measurement
|
| 51 | |
bar.IncrBy(1, time.Since(start))
|
|
50 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
51 |
bar.Increment(time.Since(start))
|
| 52 | 52 |
}
|
| 53 | 53 |
}()
|
| 54 | 54 |
}
|
| 33 | 33 |
for i := 0; i < total; i++ {
|
| 34 | 34 |
start := time.Now()
|
| 35 | 35 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 36 | |
// ewma based decorators require work duration measurement
|
| 37 | |
bar.IncrBy(1, time.Since(start))
|
|
36 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
37 |
bar.Increment(time.Since(start))
|
| 38 | 38 |
}
|
| 39 | 39 |
// wait for our bar to complete and flush
|
| 40 | 40 |
p.Wait()
|
| 42 | 42 |
priority := total - int(b.Current())
|
| 43 | 43 |
b.SetPriority(priority)
|
| 44 | 44 |
}
|
| 45 | |
// ewma based decorators require work duration measurement
|
| 46 | |
b.IncrBy(1, time.Since(start))
|
|
45 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
46 |
b.Increment(time.Since(start))
|
| 47 | 47 |
}
|
| 48 | 48 |
}()
|
| 49 | 49 |
}
|
| 66 | 66 |
for i := 0; i < total; i++ {
|
| 67 | 67 |
start := time.Now()
|
| 68 | 68 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 69 | |
// ewma based decorators require work duration measurement
|
| 70 | |
bar.IncrBy(1, time.Since(start))
|
|
69 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
70 |
bar.Increment(time.Since(start))
|
| 71 | 71 |
}
|
| 72 | 72 |
}()
|
| 73 | 73 |
}
|
| 41 | 41 |
defer wg.Done()
|
| 42 | 42 |
max := 100 * time.Millisecond
|
| 43 | 43 |
for i := 0; i < total; i++ {
|
| 44 | |
start := time.Now()
|
| 45 | 44 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 46 | |
// ewma based decorators require work duration measurement
|
| 47 | |
bar.IncrBy(1, time.Since(start))
|
|
45 |
bar.Increment()
|
| 48 | 46 |
}
|
| 49 | 47 |
}()
|
| 50 | 48 |
}
|
| 44 | 44 |
defer wg.Done()
|
| 45 | 45 |
max := 100 * time.Millisecond
|
| 46 | 46 |
for !bar.Completed() {
|
| 47 | |
start := time.Now()
|
| 48 | 47 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 49 | |
// ewma based decorators require work duration measurement
|
| 50 | |
bar.IncrBy(1, time.Since(start))
|
|
48 |
bar.Increment()
|
| 51 | 49 |
}
|
| 52 | 50 |
}()
|
| 53 | 51 |
}
|
| 36 | 36 |
for i := 0; i < total; i++ {
|
| 37 | 37 |
start := time.Now()
|
| 38 | 38 |
time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
|
| 39 | |
// ewma based decorators require work duration measurement
|
| 40 | |
bar.IncrBy(1, time.Since(start))
|
|
39 |
// since ewma decorator is used, we need to pass time.Since(start)
|
|
40 |
bar.Increment(time.Since(start))
|
| 41 | 41 |
}
|
| 42 | 42 |
// wait for our bar to complete and flush
|
| 43 | 43 |
p.Wait()
|