signal to flushedCh directly
Vladimir Bauer
9 years ago
| 180 | 180 |
return b
|
| 181 | 181 |
}
|
| 182 | 182 |
|
|
183 |
func (b *Bar) AppendPercentage() *Bar {
|
|
184 |
b.AppendFunc(func(s *Statistics) string {
|
|
185 |
completed := int(100 * float64(s.Completed) / float64(s.Total))
|
|
186 |
return fmt.Sprintf("%3d %%", completed)
|
|
187 |
})
|
|
188 |
return b
|
|
189 |
}
|
|
190 |
|
| 183 | 191 |
func (b *Bar) PrependPercentage() *Bar {
|
| 184 | 192 |
b.PrependFunc(func(s *Statistics) string {
|
| 185 | 193 |
completed := int(100 * float64(s.Completed) / float64(s.Total))
|
| 186 | |
return fmt.Sprintf("%3d %%", completed)
|
|
194 |
str := fmt.Sprintf("%3d %%", completed)
|
|
195 |
return fmt.Sprintf("%-5s", str)
|
| 187 | 196 |
})
|
| 188 | 197 |
return b
|
| 189 | 198 |
}
|
|
| 272 | 281 |
return buf
|
| 273 | 282 |
}
|
| 274 | 283 |
|
| 275 | |
func (b *Bar) flushed() {
|
| 276 | |
b.flushedCh <- struct{}{}
|
| 277 | |
}
|
| 278 | |
|
| 279 | 284 |
func (b *Bar) updateTimePerItemEstimate(items int, blockStartTime time.Time) {
|
| 280 | 285 |
lastBlockTime := time.Since(blockStartTime)
|
| 281 | 286 |
lastItemEstimate := float64(lastBlockTime) / float64(items)
|