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 @@
#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>
@ -4288,11 +4288,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

64
src/gui/statsdialog.ui

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

Loading…
Cancel
Save