/* */ #ifndef _D_SPEED_CALC_H_ #define _D_SPEED_CALC_H_ #include "common.h" #include "TimeA2.h" class SpeedCalc { private: int64_t lengthArray[2]; int32_t sw; Time cpArray[2]; int32_t maxSpeed; int32_t prevSpeed; Time start; int64_t accumulatedLength; int32_t nextInterval; bool isIntervalOver() const; void changeSw(); public: SpeedCalc() { reset(); } ~SpeedCalc() {} /** * Returns download/upload speed in byte per sec */ int32_t calculateSpeed(); int32_t calculateSpeed(const struct timeval& now); int32_t getMaxSpeed() const { return maxSpeed; } int32_t getAvgSpeed() const; void update(int bytes); void reset(); }; #endif // _D_SPEED_CALC_H_