stress Completed
Vladimir Bauer
8 years ago
| 25 | 25 | |
| 26 | 26 | for i := 0; i < totalBars; i++ { |
| 27 | 27 | name := fmt.Sprintf("Bar#%02d: ", i) |
| 28 | total := rand.Intn(120) + 10 | |
| 28 | total := rand.Intn(320) + 10 | |
| 29 | 29 | startBlock := make(chan time.Time) |
| 30 | 30 | bar := p.AddBar(int64(total), |
| 31 | 31 | mpb.PrependDecorators( |
| 40 | 40 | go func() { |
| 41 | 41 | defer wg.Done() |
| 42 | 42 | max := 100 * time.Millisecond |
| 43 | for i := 0; i < total; i++ { | |
| 43 | for !bar.Completed() { | |
| 44 | 44 | startBlock <- time.Now() |
| 45 | 45 | time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) |
| 46 | 46 | bar.Increment() |