anacrolix / torrent

Full-featured BitTorrent client package and utilities
Mozilla Public License 2.0
5.58k stars 630 forks source link

Download speed info in (*File) itself #731

Open glblduh opened 2 years ago

glblduh commented 2 years ago

Can this feature be added to remove the need to calculate the speed in the application itself. This will be beneficial for many torrents because it removes the need to calculate for the download speed in each file in each torrents.

anacrolix commented 2 years ago

How do you currently do it? You could collect the piece states for all pieces that are in a file and calculate their byte contributions and sum them up? Does that sound right?

glblduh commented 2 years ago

It can be the for the entire torrent. Like a method of the Torrent struct that outputs the current calculated download speed.

I currently do it with a concurrent function that infinitely iterates through all of the torrents to calculate its download and upload speed.

anacrolix commented 2 years ago

Ah yeah I mean how are you calculating speeds per File? I would prefer not to encode speed into the client itself, it should be relatively straight forward to calculate from the piece states and bytes per piece for each file, and calculating the difference since the last calculation for each File (or Torrent etc.). I would be okay with putting some helpers for doing it somewhere in the module.

glblduh commented 2 years ago

I think the completed bytes of each file can be used for calculation, but I haven't tried it.