Browse Source

Merge pull request #8349 from Chocobo1/stats

Improve stats dialog
adaptive-webui-19844
Mike Tzou 7 years ago committed by GitHub
parent
commit
47048d8410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/base/bittorrent/session.cpp
  2. 5
      src/gui/statsdialog.cpp
  3. 64
      src/gui/statsdialog.ui

9
src/base/bittorrent/session.cpp

@ -29,10 +29,10 @@ @@ -29,10 +29,10 @@
#include "session.h"
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <string>
#include <vector>
#include <QCoreApplication>
#include <QDateTime>
@ -4288,11 +4288,10 @@ void Session::handleSessionStatsAlert(libt::session_stats_alert *p) @@ -4288,11 +4288,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]

5
src/gui/statsdialog.cpp

@ -77,7 +77,10 @@ void StatsDialog::update() @@ -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

64
src/gui/statsdialog.ui

@ -6,8 +6,8 @@ @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>286</width>
<height>401</height>
<width>265</width>
<height>457</height>
</rect>
</property>
<property name="windowTitle">
@ -20,71 +20,71 @@ @@ -20,71 +20,71 @@
<string>User statistics</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="11" column="0">
<item row="3" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="labelWaste">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelPeersText">
<property name="text">
<string>Total peer connections:</string>
<string>Connected peers:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QLabel" name="labelGlobalRatioText">
<property name="text">
<string>Global ratio:</string>
<string>All-time share ratio:</string>
</property>
</widget>
</item>
<item row="11" column="1" alignment="Qt::AlignRight">
<item row="4" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="labelPeers">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="labelAlltimeDLText">
<property name="text">
<string>Alltime download:</string>
<string>All-time download:</string>
</property>
</widget>
</item>
<item row="1" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="labelAlltimeUL">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="labelAlltimeDL">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelAlltimeULText">
<item row="2" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="labelGlobalRatio">
<property name="text">
<string>Alltime upload:</string>
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item row="3" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="labelGlobalRatio">
<item row="3" column="0">
<widget class="QLabel" name="labelWasteText">
<property name="text">
<string notr="true">TextLabel</string>
<string>Session waste:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelWasteText">
<item row="0" column="0">
<widget class="QLabel" name="labelAlltimeULText">
<property name="text">
<string>Total waste (this session):</string>
<string>All-time upload:</string>
</property>
</widget>
</item>
<item row="2" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="labelWaste">
<item row="0" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="labelAlltimeUL">
<property name="text">
<string notr="true">TextLabel</string>
</property>
@ -99,31 +99,31 @@ @@ -99,31 +99,31 @@
<string>Cache statistics</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<item row="0" column="0">
<widget class="QLabel" name="labelCacheHitsText">
<property name="text">
<string>Read cache hits:</string>
</property>
</widget>
</item>
<item row="1" column="1" alignment="Qt::AlignRight">
<item row="0" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="labelCacheHits">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="1" alignment="Qt::AlignRight">
<item row="1" column="1" alignment="Qt::AlignRight">
<widget class="QLabel" name="labelTotalBuf">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="0">
<widget class="QLabel" name="labelTotalBufText">
<property name="text">
<string>Total buffers size:</string>
<string>Total buffer size:</string>
</property>
</widget>
</item>

Loading…
Cancel
Save