From: Matt Joiner Date: Thu, 14 Oct 2021 12:14:10 +0000 (+1100) Subject: Print average download rate X-Git-Tag: v1.34.0^2~33 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=89e7e00c319651dddb7ef209da9e0ee5bab129d8;p=btrtrc.git Print average download rate --- diff --git a/cmd/torrent/main.go b/cmd/torrent/main.go index 260f51d2..c2e65801 100644 --- a/cmd/torrent/main.go +++ b/cmd/torrent/main.go @@ -347,6 +347,7 @@ func downloadErr(flags downloadFlags) error { client.WriteStatus(w) }) err = addTorrents(client, flags) + started := time.Now() if err != nil { return fmt.Errorf("adding torrents: %w", err) } @@ -356,6 +357,13 @@ func downloadErr(flags downloadFlags) error { } else { err = errors.New("y u no complete torrents?!") } + clientConnStats := client.ConnStats() + log.Printf("average download rate: %v", + humanize.Bytes(uint64( + time.Duration( + clientConnStats.BytesReadUsefulData.Int64(), + )*time.Second/time.Since(started), + ))) if flags.Seed { if len(client.Torrents()) == 0 { log.Print("no torrents to seed")