instant download and upload speed calculation with bigger sampling interval

This commit is contained in:
orignal committed 2026-11-08 17:35:55 -05:00
1 parent 9702ba83ee
commit 026d9a99ed
2 files changed
+3 -9

No files matched your search

+2 -8
View File
@@ -2175,10 +2175,7 @@ namespace torrents
auto delta = ts - m_LastBlockDownloadTimestamp;
if (delta >= BANDWIDTH_RATE_SAMPLING_INTERVAL)
{
if (m_DownloadRate)
m_DownloadRate = (m_DownloadRate + m_ReceivedSinceLastTimestamp*1000/delta)/2;
else
m_DownloadRate = m_ReceivedSinceLastTimestamp*1000/delta;
m_DownloadRate = m_ReceivedSinceLastTimestamp*1000/delta;
m_LastBlockDownloadTimestamp = ts;
m_ReceivedSinceLastTimestamp = 0;
}
@@ -2223,10 +2220,7 @@ namespace torrents
auto delta = ts - s->m_LastBlockUploadTimestamp;
if (delta >= BANDWIDTH_RATE_SAMPLING_INTERVAL)
{
if (s->m_UploadRate)
s->m_UploadRate = (s->m_UploadRate + s->m_SentSinceLastTimestamp*1000/delta)/2;
else
s->m_UploadRate = s->m_SentSinceLastTimestamp*1000/delta;
s->m_UploadRate = s->m_SentSinceLastTimestamp*1000/delta;
s->m_LastBlockUploadTimestamp = ts;
s->m_SentSinceLastTimestamp = 0;
}
+1 -1
View File
@@ -82,7 +82,7 @@ namespace torrents
constexpr size_t MAX_INCOMING_REQUESTS_QUEUE_SIZE = 32;
constexpr int PIECE_INACTIVITY_TIMEOUT = 22; // in seconds
constexpr int HANDSHAKE_RECEIVE_TIMEOUT = 20; // in seconds
constexpr int BANDWIDTH_RATE_SAMPLING_INTERVAL = 20; // in milliseconds
constexpr int BANDWIDTH_RATE_SAMPLING_INTERVAL = 250; // in milliseconds
constexpr int TORRENT_FILE_FLUSH_INTERVAL = 30; // in seconds
constexpr int TORRENT_FILE_INACTIVITY_TIMEOUT = 90; // in seconds
constexpr int TORRENT_RESUME_FILE_UPDATE_INTERVAL = 120; // in seconds