From b9ec216aa5d0796cd470465a931db4531a8038a7 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 2 Feb 2018 15:12:49 +0800 Subject: [PATCH 1/2] Redefine CacheStatus.readRatio field. Now it is defined as: CacheStatus.readRatio = (blocks read from cache) / (blocks read from disk + blocks read from cache) The 2 variables in denominator are counted separately and the formula before this change doesn't really make sense Add percentage sign to "Read cache hits" stats Also remove redundant header include --- src/base/bittorrent/session.cpp | 9 ++++----- src/gui/statsdialog.cpp | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 707761ff2..fdfd4a9f4 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -29,10 +29,10 @@ #include "session.h" +#include #include #include #include -#include #include #include @@ -4266,11 +4266,10 @@ void Session::handleSessionStatsAlert(libt::session_stats_alert *p) m_status.diskWriteQueue = p->values[m_metricIndices.peer.numPeersDownDisk]; m_status.peersCount = p->values[m_metricIndices.peer.numPeersConnected]; - const auto numBlocksRead = p->values[m_metricIndices.disk.numBlocksRead]; + const int numBlocksRead = p->values[m_metricIndices.disk.numBlocksRead]; + const int numBlocksCacheHits = p->values[m_metricIndices.disk.numBlocksCacheHits]; m_cacheStatus.totalUsedBuffers = p->values[m_metricIndices.disk.diskBlocksInUse]; - m_cacheStatus.readRatio = numBlocksRead > 0 - ? static_cast(p->values[m_metricIndices.disk.numBlocksCacheHits]) / numBlocksRead - : -1; + m_cacheStatus.readRatio = static_cast(numBlocksCacheHits) / std::max(numBlocksCacheHits + numBlocksRead, 1); m_cacheStatus.jobQueueLength = p->values[m_metricIndices.disk.queuedDiskJobs]; quint64 totalJobs = p->values[m_metricIndices.disk.writeJobs] + p->values[m_metricIndices.disk.readJobs] diff --git a/src/gui/statsdialog.cpp b/src/gui/statsdialog.cpp index 5ec64edc0..15aea6a69 100644 --- a/src/gui/statsdialog.cpp +++ b/src/gui/statsdialog.cpp @@ -77,7 +77,10 @@ void StatsDialog::update() : "-"); // Cache hits qreal readRatio = cs.readRatio; - m_ui->labelCacheHits->setText((readRatio >= 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "-"); + m_ui->labelCacheHits->setText(QString("%1%").arg( + readRatio > 0 + ? Utils::String::fromDouble(100 * readRatio, 2) + : "0")); // Buffers size m_ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers * 16 * 1024)); // Disk overload (100%) equivalent From e31ec20ec48a6b5b7f7656847cd3efdc679802ce Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 2 Feb 2018 15:40:13 +0800 Subject: [PATCH 2/2] Clarify some terms in stats dialog Reorder list --- src/gui/statsdialog.ui | 64 +++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/gui/statsdialog.ui b/src/gui/statsdialog.ui index ef2ebbf08..dc81e8cbe 100644 --- a/src/gui/statsdialog.ui +++ b/src/gui/statsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 286 - 401 + 265 + 457 @@ -20,71 +20,71 @@ User statistics - + + + + TextLabel + + + + - Total peer connections: + Connected peers: - + - Global ratio: + All-time share ratio: - + TextLabel - + - Alltime download: + All-time download: - - - TextLabel - - - - TextLabel - - + + - Alltime upload: + TextLabel - - + + - TextLabel + Session waste: - - + + - Total waste (this session): + All-time upload: - - + + TextLabel @@ -99,31 +99,31 @@ Cache statistics - + Read cache hits: - + TextLabel - + TextLabel - + - Total buffers size: + Total buffer size: