1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-24 05:25:37 +00:00

Fix calculation of 'Average time in queue' stat under libtorrent 1.1.x

This commit is contained in:
sledgehammer999 2017-08-14 17:27:31 +03:00
parent ea749bb052
commit c2a8970109
No known key found for this signature in database
GPG Key ID: 6E4A2D025B7CC9A2
2 changed files with 17 additions and 1 deletions

View File

@ -1083,6 +1083,15 @@ void Session::initMetrics()
m_metricIndices.disk.numBlocksCacheHits = libt::find_metric_idx("disk.num_blocks_cache_hits");
Q_ASSERT(m_metricIndices.disk.numBlocksCacheHits >= 0);
m_metricIndices.disk.writeJobs = libt::find_metric_idx("disk.num_write_ops");
Q_ASSERT(m_metricIndices.disk.writeJobs >= 0);
m_metricIndices.disk.readJobs = libt::find_metric_idx("disk.num_read_ops");
Q_ASSERT(m_metricIndices.disk.readJobs >= 0);
m_metricIndices.disk.hashJobs = libt::find_metric_idx("disk.num_blocks_hashed");
Q_ASSERT(m_metricIndices.disk.hashJobs >= 0);
m_metricIndices.disk.queuedDiskJobs = libt::find_metric_idx("disk.queued_disk_jobs");
Q_ASSERT(m_metricIndices.disk.queuedDiskJobs >= 0);
@ -3912,7 +3921,11 @@ void Session::handleSessionStatsAlert(libt::session_stats_alert *p)
? static_cast<qreal>(p->values[m_metricIndices.disk.numBlocksCacheHits]) / numBlocksRead
: -1;
m_cacheStatus.jobQueueLength = p->values[m_metricIndices.disk.queuedDiskJobs];
m_cacheStatus.averageJobTime = p->values[m_metricIndices.disk.diskJobTime];
quint64 totalJobs = p->values[m_metricIndices.disk.writeJobs] + p->values[m_metricIndices.disk.readJobs]
+ p->values[m_metricIndices.disk.hashJobs];
m_cacheStatus.averageJobTime = totalJobs > 0
? (p->values[m_metricIndices.disk.diskJobTime] / totalJobs) : 0;
emit statsUpdated();
}

View File

@ -188,6 +188,9 @@ namespace BitTorrent
int diskBlocksInUse = 0;
int numBlocksRead = 0;
int numBlocksCacheHits = 0;
int writeJobs = 0;
int readJobs = 0;
int hashJobs = 0;
int queuedDiskJobs = 0;
int diskJobTime = 0;
} disk;