mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-26 19:26:59 +03:00
Don't use removed stat metric in libtorrent 2.0
For now, the metric is not entirely removed due to WebAPI still needs to access it.
This commit is contained in:
parent
0ebd864db9
commit
90a1ea4281
6 changed files with 20 additions and 6 deletions
|
@ -38,6 +38,6 @@ namespace BitTorrent
|
||||||
quint64 jobQueueLength = 0;
|
quint64 jobQueueLength = 0;
|
||||||
quint64 averageJobTime = 0;
|
quint64 averageJobTime = 0;
|
||||||
quint64 queuedBytes = 0;
|
quint64 queuedBytes = 0;
|
||||||
qreal readRatio = 0.0;
|
qreal readRatio = 0; // TODO: remove when LIBTORRENT_VERSION_NUM >= 20000
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1220,8 +1220,10 @@ void Session::initMetrics()
|
||||||
m_metricIndices.disk.numBlocksRead = lt::find_metric_idx("disk.num_blocks_read");
|
m_metricIndices.disk.numBlocksRead = lt::find_metric_idx("disk.num_blocks_read");
|
||||||
Q_ASSERT(m_metricIndices.disk.numBlocksRead >= 0);
|
Q_ASSERT(m_metricIndices.disk.numBlocksRead >= 0);
|
||||||
|
|
||||||
|
#if (LIBTORRENT_VERSION_NUM < 20000)
|
||||||
m_metricIndices.disk.numBlocksCacheHits = lt::find_metric_idx("disk.num_blocks_cache_hits");
|
m_metricIndices.disk.numBlocksCacheHits = lt::find_metric_idx("disk.num_blocks_cache_hits");
|
||||||
Q_ASSERT(m_metricIndices.disk.numBlocksCacheHits >= 0);
|
Q_ASSERT(m_metricIndices.disk.numBlocksCacheHits >= 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
m_metricIndices.disk.writeJobs = lt::find_metric_idx("disk.num_write_ops");
|
m_metricIndices.disk.writeJobs = lt::find_metric_idx("disk.num_write_ops");
|
||||||
Q_ASSERT(m_metricIndices.disk.writeJobs >= 0);
|
Q_ASSERT(m_metricIndices.disk.writeJobs >= 0);
|
||||||
|
@ -4908,11 +4910,14 @@ void Session::handleSessionStatsAlert(const lt::session_stats_alert *p)
|
||||||
m_status.peersCount = stats[m_metricIndices.peer.numPeersConnected];
|
m_status.peersCount = stats[m_metricIndices.peer.numPeersConnected];
|
||||||
|
|
||||||
const int64_t numBlocksRead = stats[m_metricIndices.disk.numBlocksRead];
|
const int64_t numBlocksRead = stats[m_metricIndices.disk.numBlocksRead];
|
||||||
const int64_t numBlocksCacheHits = stats[m_metricIndices.disk.numBlocksCacheHits];
|
|
||||||
m_cacheStatus.totalUsedBuffers = stats[m_metricIndices.disk.diskBlocksInUse];
|
m_cacheStatus.totalUsedBuffers = stats[m_metricIndices.disk.diskBlocksInUse];
|
||||||
m_cacheStatus.readRatio = static_cast<qreal>(numBlocksCacheHits) / std::max<int64_t>(numBlocksCacheHits + numBlocksRead, 1);
|
|
||||||
m_cacheStatus.jobQueueLength = stats[m_metricIndices.disk.queuedDiskJobs];
|
m_cacheStatus.jobQueueLength = stats[m_metricIndices.disk.queuedDiskJobs];
|
||||||
|
|
||||||
|
#if (LIBTORRENT_VERSION_NUM < 20000)
|
||||||
|
const int64_t numBlocksCacheHits = stats[m_metricIndices.disk.numBlocksCacheHits];
|
||||||
|
m_cacheStatus.readRatio = static_cast<qreal>(numBlocksCacheHits) / std::max<int64_t>((numBlocksCacheHits + numBlocksRead), 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
const int64_t totalJobs = stats[m_metricIndices.disk.writeJobs] + stats[m_metricIndices.disk.readJobs]
|
const int64_t totalJobs = stats[m_metricIndices.disk.writeJobs] + stats[m_metricIndices.disk.readJobs]
|
||||||
+ stats[m_metricIndices.disk.hashJobs];
|
+ stats[m_metricIndices.disk.hashJobs];
|
||||||
m_cacheStatus.averageJobTime = (totalJobs > 0)
|
m_cacheStatus.averageJobTime = (totalJobs > 0)
|
||||||
|
|
|
@ -197,7 +197,9 @@ namespace BitTorrent
|
||||||
{
|
{
|
||||||
int diskBlocksInUse = -1;
|
int diskBlocksInUse = -1;
|
||||||
int numBlocksRead = -1;
|
int numBlocksRead = -1;
|
||||||
|
#if (LIBTORRENT_VERSION_NUM < 20000)
|
||||||
int numBlocksCacheHits = -1;
|
int numBlocksCacheHits = -1;
|
||||||
|
#endif
|
||||||
int writeJobs = -1;
|
int writeJobs = -1;
|
||||||
int readJobs = -1;
|
int readJobs = -1;
|
||||||
int hashJobs = -1;
|
int hashJobs = -1;
|
||||||
|
|
|
@ -52,6 +52,11 @@ StatsDialog::StatsDialog(QWidget *parent)
|
||||||
connect(BitTorrent::Session::instance(), &BitTorrent::Session::statsUpdated
|
connect(BitTorrent::Session::instance(), &BitTorrent::Session::statsUpdated
|
||||||
, this, &StatsDialog::update);
|
, this, &StatsDialog::update);
|
||||||
|
|
||||||
|
#if (LIBTORRENT_VERSION_NUM >= 20000)
|
||||||
|
m_ui->labelCacheHitsText->hide();
|
||||||
|
m_ui->labelCacheHits->hide();
|
||||||
|
#endif
|
||||||
|
|
||||||
Utils::Gui::resize(this);
|
Utils::Gui::resize(this);
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
@ -78,11 +83,13 @@ void StatsDialog::update()
|
||||||
((atd > 0) && (atu > 0))
|
((atd > 0) && (atu > 0))
|
||||||
? Utils::String::fromDouble(static_cast<qreal>(atu) / atd, 2)
|
? Utils::String::fromDouble(static_cast<qreal>(atu) / atd, 2)
|
||||||
: "-");
|
: "-");
|
||||||
|
#if (LIBTORRENT_VERSION_NUM < 20000)
|
||||||
// Cache hits
|
// Cache hits
|
||||||
qreal readRatio = cs.readRatio;
|
const qreal readRatio = cs.readRatio;
|
||||||
m_ui->labelCacheHits->setText(QString::fromLatin1("%1%").arg((readRatio > 0)
|
m_ui->labelCacheHits->setText(QString::fromLatin1("%1%").arg((readRatio > 0)
|
||||||
? Utils::String::fromDouble(100 * readRatio, 2)
|
? Utils::String::fromDouble(100 * readRatio, 2)
|
||||||
: QLatin1String("0")));
|
: QLatin1String("0")));
|
||||||
|
#endif
|
||||||
// Buffers size
|
// Buffers size
|
||||||
m_ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers * 16 * 1024));
|
m_ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers * 16 * 1024));
|
||||||
// Disk overload (100%) equivalent
|
// Disk overload (100%) equivalent
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Ui
|
||||||
class StatsDialog;
|
class StatsDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
class StatsDialog : public QDialog
|
class StatsDialog final : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace
|
||||||
map[KEY_TRANSFER_GLOBAL_RATIO] = ((atd > 0) && (atu > 0)) ? Utils::String::fromDouble(static_cast<qreal>(atu) / atd, 2) : "-";
|
map[KEY_TRANSFER_GLOBAL_RATIO] = ((atd > 0) && (atu > 0)) ? Utils::String::fromDouble(static_cast<qreal>(atu) / atd, 2) : "-";
|
||||||
map[KEY_TRANSFER_TOTAL_PEER_CONNECTIONS] = sessionStatus.peersCount;
|
map[KEY_TRANSFER_TOTAL_PEER_CONNECTIONS] = sessionStatus.peersCount;
|
||||||
|
|
||||||
const qreal readRatio = cacheStatus.readRatio;
|
const qreal readRatio = cacheStatus.readRatio; // TODO: remove when LIBTORRENT_VERSION_NUM >= 20000
|
||||||
map[KEY_TRANSFER_READ_CACHE_HITS] = (readRatio > 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "0";
|
map[KEY_TRANSFER_READ_CACHE_HITS] = (readRatio > 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "0";
|
||||||
map[KEY_TRANSFER_TOTAL_BUFFERS_SIZE] = cacheStatus.totalUsedBuffers * 16 * 1024;
|
map[KEY_TRANSFER_TOTAL_BUFFERS_SIZE] = cacheStatus.totalUsedBuffers * 16 * 1024;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue