/* */ #ifndef D_SPEED_CALC_H #define D_SPEED_CALC_H #include "common.h" #include #include "TimerA2.h" namespace aria2 { class SpeedCalc { private: std::deque> timeSlots_; Timer start_; int64_t accumulatedLength_; int64_t bytesWindow_; int maxSpeed_; void removeStaleTimeSlot(const Timer& now); public: SpeedCalc(); /** * Returns download/upload speed in byte per sec */ int calculateSpeed(); int calculateNewestSpeed(int seconds); int getMaxSpeed() const { return maxSpeed_; } int calculateAvgSpeed() const; void update(size_t bytes); void reset(); }; } // namespace aria2 #endif // D_SPEED_CALC_H