]> Sergey Matveev's repositories - btrtrc.git/commitdiff
cmd/torrent: Dump download statistics
authorMatt Joiner <anacrolix@gmail.com>
Mon, 20 Sep 2021 04:17:58 +0000 (14:17 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 20 Sep 2021 04:17:58 +0000 (14:17 +1000)
cmd/torrent/main.go

index 624c2a4ee97b082e7cde31ba637f8dcca7256877..757ecdc75f2a75bea238211134a2ac17118bf685 100644 (file)
@@ -369,6 +369,15 @@ func downloadErr(flags downloadFlags) error {
                        <-stop.C()
                }
        }
+       spew.Dump(expvar.Get("torrent").(*expvar.Map).Get("chunks received"))
+       spew.Dump(client.ConnStats())
+       clStats := client.ConnStats()
+       sentOverhead := clStats.BytesWritten.Int64() - clStats.BytesWrittenData.Int64()
+       log.Printf(
+               "client read %v, %v was useful data. sent %v non-data bytes",
+               humanize.Bytes(uint64(clStats.BytesRead.Int64())),
+               100*float64(clStats.BytesReadUsefulData.Int64())/float64(clStats.BytesRead.Int64()),
+               humanize.Bytes(uint64(sentOverhead)))
        return nil
 }