Commit 33694eaf authored by Arjen Hiemstra's avatar Arjen Hiemstra

Divide network speeds by 2

We update the network speed every 2s to match the daemon update rate.
However, this means that when calculating the difference between the
current and the previous, we get twice the amount since we are a
calculating the difference over 2s. So divide by 2 to get the byte rate
per second.


(cherry picked from commit cf19c92b)
parent f0c7d38b
......@@ -46,14 +46,16 @@ NetworkManagerDevice::NetworkManagerDevice(const QString &id, QSharedPointer<Net
auto newDownload = m_statistics->rxBytes();
auto previousDownload = m_totalDownloadSensor->value().toULongLong();
if (previousDownload > 0) {
m_downloadSensor->setValue(newDownload - previousDownload);
// Our update interval is 2s, so to get bytes/sec we need to divide
// by 2.
m_downloadSensor->setValue((newDownload - previousDownload) / 2.0);
}
m_totalDownloadSensor->setValue(newDownload);
auto newUpload = m_statistics->txBytes();
auto previousUpload = m_totalUploadSensor->value().toULongLong();
if (previousUpload > 0) {
m_uploadSensor->setValue(newUpload - previousUpload);
m_uploadSensor->setValue((newUpload - previousUpload) / 2.0);
}
m_totalUploadSensor->setValue(newUpload);
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment