diff --git a/src/gui/statsdialog.cpp b/src/gui/statsdialog.cpp index 1e9afb74d..9efc18e49 100644 --- a/src/gui/statsdialog.cpp +++ b/src/gui/statsdialog.cpp @@ -90,21 +90,13 @@ void StatsDialog::update() // From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read // to complete before it receives or sends any more data on the socket. It's a metric of how disk bound you are. - // num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake) - const auto torrents = BitTorrent::Session::instance()->torrents(); - const quint32 peers = std::accumulate(torrents.cbegin(), torrents.cend(), 0, [](const quint32 acc, const BitTorrent::TorrentHandle *torrent) - { - return (acc + torrent->peersCount()); - }); + m_ui->labelWriteStarve->setText(QString("%1%").arg(((ss.diskWriteQueue > 0) && (ss.peersCount > 0)) + ? Utils::String::fromDouble((100. * ss.diskWriteQueue / ss.peersCount), 2) + : QLatin1String("0"))); + m_ui->labelReadStarve->setText(QString("%1%").arg(((ss.diskReadQueue > 0) && (ss.peersCount > 0)) + ? Utils::String::fromDouble((100. * ss.diskReadQueue / ss.peersCount), 2) + : QLatin1String("0"))); - m_ui->labelWriteStarve->setText(QString("%1%") - .arg(((ss.diskWriteQueue > 0) && (peers > 0)) - ? Utils::String::fromDouble((100. * ss.diskWriteQueue) / peers, 2) - : "0")); - m_ui->labelReadStarve->setText(QString("%1%") - .arg(((ss.diskReadQueue > 0) && (peers > 0)) - ? Utils::String::fromDouble((100. * ss.diskReadQueue) / peers, 2) - : "0")); // Disk queues m_ui->labelQueuedJobs->setText(QString::number(cs.jobQueueLength)); m_ui->labelJobsTime->setText(tr("%1 ms", "18 milliseconds").arg(cs.averageJobTime)); diff --git a/src/webui/api/synccontroller.cpp b/src/webui/api/synccontroller.cpp index 0531a70ee..17df7ca0c 100644 --- a/src/webui/api/synccontroller.cpp +++ b/src/webui/api/synccontroller.cpp @@ -110,7 +110,7 @@ namespace void processList(QVariantList prevData, const QVariantList &data, QVariantList &syncData, QVariantList &removedItems); QVariantMap generateSyncData(int acceptedResponseId, const QVariantMap &data, QVariantMap &lastAcceptedData, QVariantMap &lastData); - QVariantMap getTranserInfo() + QVariantMap getTransferInfo() { QVariantMap map; const auto *session = BitTorrent::Session::instance(); @@ -136,15 +136,12 @@ namespace map[KEY_TRANSFER_READ_CACHE_HITS] = (readRatio > 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "0"; map[KEY_TRANSFER_TOTAL_BUFFERS_SIZE] = cacheStatus.totalUsedBuffers * 16 * 1024; - // num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake) - const auto torrents = session->torrents(); - const quint32 peers = std::accumulate(torrents.cbegin(), torrents.cend(), 0, [](const quint32 acc, const BitTorrent::TorrentHandle *torrent) - { - return (acc + torrent->peersCount()); - }); - - map[KEY_TRANSFER_WRITE_CACHE_OVERLOAD] = ((sessionStatus.diskWriteQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskWriteQueue) / peers, 2) : "0"; - map[KEY_TRANSFER_READ_CACHE_OVERLOAD] = ((sessionStatus.diskReadQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskReadQueue) / peers, 2) : "0"; + map[KEY_TRANSFER_WRITE_CACHE_OVERLOAD] = ((sessionStatus.diskWriteQueue > 0) && (sessionStatus.peersCount > 0)) + ? Utils::String::fromDouble((100. * sessionStatus.diskWriteQueue / sessionStatus.peersCount), 2) + : QLatin1String("0"); + map[KEY_TRANSFER_READ_CACHE_OVERLOAD] = ((sessionStatus.diskReadQueue > 0) && (sessionStatus.peersCount > 0)) + ? Utils::String::fromDouble((100. * sessionStatus.diskReadQueue / sessionStatus.peersCount), 2) + : QLatin1String("0"); map[KEY_TRANSFER_QUEUED_IO_JOBS] = cacheStatus.jobQueueLength; map[KEY_TRANSFER_AVERAGE_TIME_QUEUE] = cacheStatus.averageJobTime; @@ -461,7 +458,7 @@ void SyncController::maindataAction() tags << tag; data["tags"] = tags; - QVariantMap serverState = getTranserInfo(); + QVariantMap serverState = getTransferInfo(); serverState[KEY_TRANSFER_FREESPACEONDISK] = getFreeDiskSpace(); serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled(); serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = session->isAltGlobalSpeedLimitEnabled();