[Pkg-owncloud-commits] [owncloud-client] 09/332: better time prediction

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Aug 14 21:06:32 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 5310a3cc1dae2ca3956f6530f1a07cd5ee24710f
Author: Eran <etherpulse at gmail.com>
Date:   Wed May 14 16:57:14 2014 +0300

    better time prediction
---
 src/mirall/progressdispatcher.h |  6 +++---
 src/mirall/utility.cpp          | 17 ++++++++++-------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/mirall/progressdispatcher.h b/src/mirall/progressdispatcher.h
index 198b039..64baabf 100644
--- a/src/mirall/progressdispatcher.h
+++ b/src/mirall/progressdispatcher.h
@@ -47,13 +47,13 @@ namespace Progress
         struct EtaEstimate {
             EtaEstimate() :  _startedTime(QDateTime::currentMSecsSinceEpoch()), _agvEtaMSecs(0),_effectivProgressPerSec(0),_sampleCount(1) {}
             
-            static const int MAX_AVG_DIVIDER=120;
+            static const int MAX_AVG_DIVIDER=60;
             static const int INITAL_WAIT_TIME=5;
             
             quint64     _startedTime ;
             quint64     _agvEtaMSecs;
             quint64     _effectivProgressPerSec;
-            quint16      _sampleCount;
+            float      _sampleCount;
             
             /**
              * reset the estiamte.
@@ -73,7 +73,7 @@ namespace Progress
                 quint64 elapsedTime = QDateTime::currentMSecsSinceEpoch() -  this->_startedTime ;
                 //don't start until you have some good data to process, prevents jittring estiamtes at the start of the syncing process                    
                 if(total != 0 && completed != 0 && elapsedTime > INITAL_WAIT_TIME ) {
-                    if(_sampleCount < MAX_AVG_DIVIDER) { _sampleCount++; }
+                    if(_sampleCount < MAX_AVG_DIVIDER) { _sampleCount+=0.01f; }
                     // (elapsedTime-1) is an hack to avoid float "rounding" issue (ie. 0.99999999999999999999....)
                     _agvEtaMSecs = _agvEtaMSecs + (((static_cast<float>(total) / completed) * elapsedTime) - (elapsedTime-1)) - this->getEtaEstimate();
                     _effectivProgressPerSec = ( total - completed ) / (1+this->getEtaEstimate()/1000);
diff --git a/src/mirall/utility.cpp b/src/mirall/utility.cpp
index f4a58e0..4557edf 100644
--- a/src/mirall/utility.cpp
+++ b/src/mirall/utility.cpp
@@ -454,14 +454,17 @@ qint64 Utility::qDateTimeToTime_t(const QDateTime& t)
 
 QString Utility::timeToDescriptiveString(quint64 msecs) 
 {
-    QList<QPair<QString,quint32> > timeMapping = QList<QPair<QString,quint32> >();    
-    timeMapping.append(QPair<QString,quint32>("years",86400*365));
-    timeMapping.append(QPair<QString,quint32>("months",86400*30));
-    timeMapping.append(QPair<QString,quint32>("days",86400));
-    timeMapping.append(QPair<QString,quint32>("hours",3600));
-    timeMapping.append(QPair<QString,quint32>("minutes",60));
-    timeMapping.append(QPair<QString,quint32>("seconds",1));
+    //TODO change to initializers list  when possible.
+   static QList<QPair<QString,quint32> > timeMapping = QList<QPair<QString,quint32> >() <<
+                                                        QPair<QString,quint32>("years",86400*365) <<
+                                                        QPair<QString,quint32>("months",86400*30) <<
+                                                        QPair<QString,quint32>("days",86400) <<
+                                                        QPair<QString,quint32>("hours",3600) <<
+                                                        QPair<QString,quint32>("minutes",60) <<
+                                                        QPair<QString,quint32>("seconds",1);
+        
     
+
     return timeToDescriptiveString(timeMapping, msecs, 1);
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list