-
Notifications
You must be signed in to change notification settings - Fork 130
Open
Labels
Description
Here is a modified version of this example, to use a ProxyWriter. It does not show the right rate:
package main
import (
"io"
"time"
"github.com/vbauerster/mpb/v8"
"github.com/vbauerster/mpb/v8/decor"
)
func main() {
var total int64 = 1024 * 1024 * 500
p := mpb.New(
mpb.WithWidth(60),
mpb.WithRefreshRate(180*time.Millisecond),
)
bar := p.New(total,
mpb.BarStyle().Rbound("|"),
mpb.PrependDecorators(
decor.Counters(decor.SizeB1000(0), "% .2f / % .2f"),
),
mpb.AppendDecorators(
decor.EwmaETA(decor.ET_STYLE_GO, 30),
decor.Name(" ] "),
decor.EwmaSpeed(decor.SizeB1024(0), "% .2f", 30),
),
)
bar.SetTotal(total, false)
bar.EnableTriggerComplete()
var data [64 * 1024]byte
pw := bar.ProxyWriter(io.Discard)
for i := 0; i < 1024; i++ {
pw.Write(data[:])
time.Sleep(time.Second / 10)
}
pw.Close()
p.Wait()
}As you can see, this is doing 64KiB of writes every tenth of a second, so that means the speed here is 640KiB/s. Right?
Running this command consistently shows me a rate output of somewhere between 60 and 90 GiB/s. What?