@@ -53,8 +53,9 @@ type ProgressBar struct {
5353
5454type progressBar struct {
5555 * mpbv8.Bar
56- size int64
57- msg string
56+ size int64
57+ msg string
58+ startTime time.Time
5859}
5960
6061// NewProgressBar creates a new progress bar.
@@ -97,7 +98,11 @@ func (p *ProgressBar) Add(prompt, name string, size int64, reader io.Reader) io.
9798 oldBar .Abort (true )
9899 }
99100
100- newBar := & progressBar {size : size , msg : fmt .Sprintf ("%s %s" , prompt , name )}
101+ newBar := & progressBar {
102+ size : size ,
103+ msg : fmt .Sprintf ("%s %s" , prompt , name ),
104+ startTime : time .Now (),
105+ }
101106 // Create a new bar if it does not exist.
102107 newBar .Bar = p .mpb .New (size ,
103108 mpbv8 .BarStyle (),
@@ -110,8 +115,12 @@ func (p *ProgressBar) Add(prompt, name string, size int64, reader io.Reader) io.
110115 mpbv8 .AppendDecorators (
111116 decor .OnComplete (decor .Counters (decor .SizeB1024 (0 ), "% .2f / % .2f" ), humanize .Bytes (uint64 (size ))),
112117 decor .OnComplete (decor .Name (" | " , decor .WCSyncWidthR ), " | " ),
113- decor .OnComplete (
114- decor .AverageSpeed (decor .SizeB1024 (0 ), "% .2f" , decor .WCSyncWidthR ), "done" ,
118+ decor .OnCompleteMeta (
119+ decor .AverageSpeed (decor .SizeB1024 (0 ), "% .2f" , decor .WCSyncWidthR ),
120+ func (_ string ) string {
121+ duration := time .Since (newBar .startTime ).Seconds ()
122+ return fmt .Sprintf ("done(%.1fs)" , duration )
123+ },
115124 ),
116125 ),
117126 )
0 commit comments