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
This commit is contained in:
Chocobo1 2018-02-02 15:12:49 +08:00
parent e487b31877
commit b9ec216aa5
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
2 changed files with 8 additions and 6 deletions

View file

@ -29,10 +29,10 @@
#include "session.h"
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <string>
#include <vector>
#include <QCoreApplication>
#include <QDateTime>
@ -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<qreal>(p->values[m_metricIndices.disk.numBlocksCacheHits]) / numBlocksRead
: -1;
m_cacheStatus.readRatio = static_cast<qreal>(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]

View file

@ -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