Browse Source

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
adaptive-webui-19844
Chocobo1 7 years ago
parent
commit
b9ec216aa5
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 9
      src/base/bittorrent/session.cpp
  2. 5
      src/gui/statsdialog.cpp

9
src/base/bittorrent/session.cpp

@ -29,10 +29,10 @@
#include "session.h" #include "session.h"
#include <algorithm>
#include <cstdlib> #include <cstdlib>
#include <queue> #include <queue>
#include <string> #include <string>
#include <vector>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDateTime> #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.diskWriteQueue = p->values[m_metricIndices.peer.numPeersDownDisk];
m_status.peersCount = p->values[m_metricIndices.peer.numPeersConnected]; 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.totalUsedBuffers = p->values[m_metricIndices.disk.diskBlocksInUse];
m_cacheStatus.readRatio = numBlocksRead > 0 m_cacheStatus.readRatio = static_cast<qreal>(numBlocksCacheHits) / std::max(numBlocksCacheHits + numBlocksRead, 1);
? static_cast<qreal>(p->values[m_metricIndices.disk.numBlocksCacheHits]) / numBlocksRead
: -1;
m_cacheStatus.jobQueueLength = p->values[m_metricIndices.disk.queuedDiskJobs]; m_cacheStatus.jobQueueLength = p->values[m_metricIndices.disk.queuedDiskJobs];
quint64 totalJobs = p->values[m_metricIndices.disk.writeJobs] + p->values[m_metricIndices.disk.readJobs] quint64 totalJobs = p->values[m_metricIndices.disk.writeJobs] + p->values[m_metricIndices.disk.readJobs]

5
src/gui/statsdialog.cpp

@ -77,7 +77,10 @@ void StatsDialog::update()
: "-"); : "-");
// Cache hits // Cache hits
qreal readRatio = cs.readRatio; 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 // 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

Loading…
Cancel
Save