-
Notifications
You must be signed in to change notification settings - Fork 272
Open
Description
package main
import (
"sync"
"time"
"github.com/cheggaaa/pb/v3"
)
func main() {
count := 5
var wg sync.WaitGroup
wg.Add(count)
// pool requires atleast one bar to start
root := pb.New(count)
pool := pb.NewPool(root)
_ = pool.Start()
for i := 0; i < count; i++ {
go func() {
defer func() {
root.Increment()
defer wg.Done()
}()
bar := pb.StartNew(1000)
bar.Set(pb.CleanOnFinish, true)
pool.Add(bar)
for i := 0; i < 1000; i++ {
time.Sleep(time.Millisecond)
bar.Increment()
}
bar.Finish()
}()
}
wg.Wait()
pool.Stop()
}
Got:
5 / 5 [-------------------------------------------------------------------->] 100.00% ? p/s
1000 / 1000 [------------------------------------------------------------] 100.00% 1076 p/s
1000 / 1000 [------------------------------------------------------------] 100.00% 1076 p/s
1000 / 1000 [------------------------------------------------------------] 100.00% 1076 p/s
1000 / 1000 [------------------------------------------------------------] 100.00% 1076 p/s
1000 / 1000 [------------------------------------------------------------] 100.00% 1076 p/s
Expected:
5 / 5 [-------------------------------------------------------------------->] 100.00% ? p/s
Metadata
Metadata
Assignees
Labels
No labels