cavaliergopher / grab

A download manager package for Go
BSD 3-Clause "New" or "Revised" License
1.38k stars 151 forks source link

Download Speed #6

Closed ohenepee closed 8 years ago

ohenepee commented 8 years ago

How can I get the download speed?

ohenepee commented 8 years ago

Found this ONLINE... maybe you could integrate it as a convenient function

transfer_speed = bytes_transferred / ( current_time - start_time)

cavaliercoder commented 8 years ago

Response.AverageBytesPerSecond() will give you the average speed over the duration of the transfer and is constantly updated while the transfer is in process. It works precisely how you described.

I'm looking to implement a CurrentBytesPerSecond function, but this will require an additional timer to mark the passage of each second. It's also frightfully difficult to produce nice steady and accurate numbers when updating on a timer.