-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid rate calculation #135
Comments
we can bring it back once we understand this issue: vbauerster/mpb#135 Change-Id: I2cbdcfc260786e1ab08d1badc78770a792785650
Implementation of diff --git a/_examples/io/main.go b/_examples/io/main.go
index 252a967..eeae8d9 100644
--- a/_examples/io/main.go
+++ b/_examples/io/main.go
@@ -11,8 +11,20 @@ import (
)
func main() {
- var total int64 = 1024 * 1024 * 500
- reader := io.LimitReader(rand.Reader, total)
+ var total int64 = 64 * 1024 * 1024
+
+ r, w := io.Pipe()
+
+ go func() {
+ for i := 0; i < 1024; i++ {
+ _, err := io.Copy(w, io.LimitReader(rand.Reader, 64*1024))
+ if err != nil {
+ panic(err)
+ }
+ time.Sleep(time.Second / 10)
+ }
+ w.Close()
+ }()
p := mpb.New(
mpb.WithWidth(60),
@@ -27,12 +39,12 @@ func main() {
mpb.AppendDecorators(
decor.EwmaETA(decor.ET_STYLE_GO, 30),
decor.Name(" ] "),
- decor.EwmaSpeed(decor.SizeB1024(0), "% .2f", 30),
+ decor.EwmaSpeed(decor.SizeB1024(0), "% .2f", 60),
),
)
// create proxy reader
- proxyReader := bar.ProxyReader(reader)
+ proxyReader := bar.ProxyReader(r)
defer proxyReader.Close()
// copy from proxyReader, ignoring errors |
Hmm, I'm surprised that whether you use ProxyReader or ProxyWriter makes a difference - does this mean that the Proxy measurements are starting and also stopping clocks that only run during the Read or Write call? How might I reliably obtain the overall io.Copy speed, considering that either the Reader or Writer might be slow? |
Here is a modified version of this example, to use a ProxyWriter. It does not show the right rate:
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?
The text was updated successfully, but these errors were encountered: