/* */ #ifndef D_SPEED_CALC_H #define D_SPEED_CALC_H #include "common.h" #include "TimerA2.h" namespace aria2 { class SpeedCalc { private: int64_t lengthArray_[2]; int sw_; Timer cpArray_[2]; int maxSpeed_; int prevSpeed_; Timer start_; int64_t accumulatedLength_; time_t nextInterval_; bool isIntervalOver() const; bool isIntervalOver(int64_t milliElapsed) const; void changeSw(); public: SpeedCalc(); /** * Returns download/upload speed in byte per sec */ int calculateSpeed(); int getMaxSpeed() const { return maxSpeed_; } int calculateAvgSpeed() const; void update(size_t bytes); void reset(); }; } // namespace aria2 #endif // D_SPEED_CALC_H