summaryrefslogtreecommitdiff
path: root/src/SpeedCalc.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-01-11 23:29:58 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-01-11 23:29:58 +0900
commit1ad815061b5c8d54c7288407eff7f63db4f36c63 (patch)
tree8d00b501ddeb2ddf4c75b839394728b41efa94ff /src/SpeedCalc.h
parentc893d8286779533bfd652c6de8394cf32f4ca835 (diff)
Rewritten SpeedCalc
Diffstat (limited to 'src/SpeedCalc.h')
-rw-r--r--src/SpeedCalc.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/SpeedCalc.h b/src/SpeedCalc.h
index c41574f6..b337bdcb 100644
--- a/src/SpeedCalc.h
+++ b/src/SpeedCalc.h
@@ -36,29 +36,25 @@
#define D_SPEED_CALC_H
#include "common.h"
+
+#include <deque>
+
#include "TimerA2.h"
namespace aria2 {
class SpeedCalc {
private:
- int64_t lengthArray_[2];
- int sw_;
- Timer cpArray_[2];
- int maxSpeed_;
- int prevSpeed_;
+ std::deque<std::pair<int64_t, size_t> > timeSlots_;
Timer start_;
int64_t accumulatedLength_;
- time_t nextInterval_;
-
- bool isIntervalOver(int64_t milliElapsed) const;
+ int64_t bytesWindow_;
+ int maxSpeed_;
- void changeSw();
+ void removeStaleTimeSlot(int64_t now);
public:
SpeedCalc();
- bool isIntervalOver() const;
-
/**
* Returns download/upload speed in byte per sec
*/