mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-02 21:52:32 -06:00
Performance improvement on ARM
This commit is contained in:
@@ -81,7 +81,7 @@ using namespace libtorrent;
|
||||
QBtSession* QBtSession::m_instance = 0;
|
||||
|
||||
const int MAX_TRACKER_ERRORS = 2;
|
||||
const float MAX_RATIO = 100.;
|
||||
const qreal MAX_RATIO = 100.;
|
||||
enum VersionType { NORMAL,ALPHA,BETA,RELEASE_CANDIDATE,DEVEL };
|
||||
|
||||
// Main constructor
|
||||
@@ -199,7 +199,7 @@ void QBtSession::processBigRatios() {
|
||||
if(!h.is_valid()) continue;
|
||||
if(h.is_seed()) {
|
||||
const QString hash = h.hash();
|
||||
const float ratio = getRealRatio(hash);
|
||||
const qreal ratio = getRealRatio(hash);
|
||||
qDebug("Ratio: %f (limit: %f)", ratio, ratio_limit);
|
||||
if(ratio <= MAX_RATIO && ratio >= ratio_limit) {
|
||||
if(high_ratio_action == REMOVE_ACTION) {
|
||||
@@ -1396,7 +1396,7 @@ bool QBtSession::enableDHT(bool b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
float QBtSession::getRealRatio(QString hash) const{
|
||||
qreal QBtSession::getRealRatio(QString hash) const{
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
if(!h.is_valid()) {
|
||||
return 0.;
|
||||
@@ -1408,7 +1408,7 @@ float QBtSession::getRealRatio(QString hash) const{
|
||||
return 0;
|
||||
return 101;
|
||||
}
|
||||
float ratio = (float)h.all_time_upload()/(float)h.total_done();
|
||||
qreal ratio = (float)h.all_time_upload()/(float)h.total_done();
|
||||
Q_ASSERT(ratio >= 0.);
|
||||
if(ratio > 100.)
|
||||
ratio = 100.;
|
||||
@@ -1732,7 +1732,7 @@ void QBtSession::setUploadRateLimit(long rate) {
|
||||
|
||||
// Torrents will a ratio superior to the given value will
|
||||
// be automatically deleted
|
||||
void QBtSession::setMaxRatio(float ratio) {
|
||||
void QBtSession::setMaxRatio(qreal ratio) {
|
||||
if(ratio < 0) ratio = -1.;
|
||||
if(ratio_limit == -1 && ratio != -1) {
|
||||
Q_ASSERT(!BigRatioTimer);
|
||||
@@ -2460,14 +2460,14 @@ void QBtSession::processDownloadedFile(QString url, QString file_path) {
|
||||
// Return current download rate for the BT
|
||||
// session. Payload means that it only take into
|
||||
// account "useful" part of the rate
|
||||
float QBtSession::getPayloadDownloadRate() const{
|
||||
qreal QBtSession::getPayloadDownloadRate() const{
|
||||
return s->status().payload_download_rate;
|
||||
}
|
||||
|
||||
// Return current upload rate for the BT
|
||||
// session. Payload means that it only take into
|
||||
// account "useful" part of the rate
|
||||
float QBtSession::getPayloadUploadRate() const{
|
||||
qreal QBtSession::getPayloadUploadRate() const{
|
||||
return s->status().payload_upload_rate;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,11 +76,11 @@ public:
|
||||
QTorrentHandle getTorrentHandle(QString hash) const;
|
||||
std::vector<libtorrent::torrent_handle> getTorrents() const;
|
||||
bool isFilePreviewPossible(QString fileHash) const;
|
||||
float getPayloadDownloadRate() const;
|
||||
float getPayloadUploadRate() const;
|
||||
qreal getPayloadDownloadRate() const;
|
||||
qreal getPayloadUploadRate() const;
|
||||
libtorrent::session_status getSessionStatus() const;
|
||||
int getListenPort() const;
|
||||
float getRealRatio(QString hash) const;
|
||||
qreal getRealRatio(QString hash) const;
|
||||
QHash<QString, TrackerInfos> getTrackersInfo(QString hash) const;
|
||||
bool hasActiveTorrents() const;
|
||||
bool hasDownloadingTorrents() const;
|
||||
@@ -129,7 +129,7 @@ public slots:
|
||||
void setMaxUploadsPerTorrent(int max);
|
||||
void setDownloadRateLimit(long rate);
|
||||
void setUploadRateLimit(long rate);
|
||||
void setMaxRatio(float ratio);
|
||||
void setMaxRatio(qreal ratio);
|
||||
void setDHTPort(int dht_port);
|
||||
void setProxySettings(const libtorrent::proxy_settings &proxySettings);
|
||||
void setSessionSettings(const libtorrent::session_settings &sessionSettings);
|
||||
@@ -233,7 +233,7 @@ private:
|
||||
// Settings
|
||||
bool preAllocateAll;
|
||||
bool addInPause;
|
||||
float ratio_limit;
|
||||
qreal ratio_limit;
|
||||
int high_ratio_action;
|
||||
bool UPnPEnabled;
|
||||
bool LSDEnabled;
|
||||
|
||||
@@ -88,12 +88,12 @@ qlonglong QTorrentHandle::next_announce_s() const {
|
||||
return torrent_handle::status().next_announce.total_seconds();
|
||||
}
|
||||
|
||||
float QTorrentHandle::progress() const {
|
||||
qreal QTorrentHandle::progress() const {
|
||||
if(!torrent_handle::status().total_wanted)
|
||||
return 0.;
|
||||
if (torrent_handle::status().total_wanted_done == torrent_handle::status().total_wanted)
|
||||
return 1.;
|
||||
float progress = (float)torrent_handle::status().total_wanted_done/(float)torrent_handle::status().total_wanted;
|
||||
qreal progress = (float)torrent_handle::status().total_wanted_done/(float)torrent_handle::status().total_wanted;
|
||||
Q_ASSERT(progress >= 0. && progress <= 1.);
|
||||
return progress;
|
||||
}
|
||||
@@ -159,11 +159,11 @@ size_type QTorrentHandle::total_wanted() const {
|
||||
return torrent_handle::status().total_wanted;
|
||||
}
|
||||
|
||||
float QTorrentHandle::download_payload_rate() const {
|
||||
qreal QTorrentHandle::download_payload_rate() const {
|
||||
return torrent_handle::status().download_payload_rate;
|
||||
}
|
||||
|
||||
float QTorrentHandle::upload_payload_rate() const {
|
||||
qreal QTorrentHandle::upload_payload_rate() const {
|
||||
return torrent_handle::status().upload_payload_rate;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
//
|
||||
QString hash() const;
|
||||
QString name() const;
|
||||
float progress() const;
|
||||
qreal progress() const;
|
||||
libtorrent::bitfield pieces() const;
|
||||
QString current_tracker() const;
|
||||
bool is_paused() const;
|
||||
@@ -66,8 +66,8 @@ public:
|
||||
int num_pieces() const;
|
||||
libtorrent::size_type total_wanted_done() const;
|
||||
libtorrent::size_type total_wanted() const;
|
||||
float download_payload_rate() const;
|
||||
float upload_payload_rate() const;
|
||||
qreal download_payload_rate() const;
|
||||
qreal upload_payload_rate() const;
|
||||
int num_connections() const;
|
||||
int connections_limit() const;
|
||||
int num_peers() const;
|
||||
|
||||
@@ -43,7 +43,7 @@ class SpeedSample {
|
||||
public:
|
||||
SpeedSample(){}
|
||||
void addSample(int s);
|
||||
float average() const;
|
||||
qreal average() const;
|
||||
void clear();
|
||||
|
||||
private:
|
||||
@@ -83,7 +83,7 @@ void SpeedSample::addSample(int s)
|
||||
m_speedSamples.removeFirst();
|
||||
}
|
||||
|
||||
float SpeedSample::average() const
|
||||
qreal SpeedSample::average() const
|
||||
{
|
||||
if(m_speedSamples.empty()) return 0;
|
||||
qlonglong sum = 0;
|
||||
@@ -114,7 +114,7 @@ qlonglong TorrentSpeedMonitor::getETA(const QString &hash) const
|
||||
QMutexLocker locker(&m_mutex);
|
||||
QTorrentHandle h = m_session->getTorrentHandle(hash);
|
||||
if(h.is_paused() || !m_samples.contains(hash)) return -1;
|
||||
const float speed_average = m_samples.value(hash).average();
|
||||
const qreal speed_average = m_samples.value(hash).average();
|
||||
if(speed_average == 0) return -1;
|
||||
return (h.total_wanted() - h.total_done()) / speed_average;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user