diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 16:57:45 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 16:57:45 +0200 |
commit | 2a3ebac62eb6dd88122c0f447ea90ce368373d3a (patch) | |
tree | fae5c18deaecfb6f39d4d66dd3de8ce730b2025b /library/statistics.h | |
parent | 1.17 (diff) | |
download | FreeFileSync-2a3ebac62eb6dd88122c0f447ea90ce368373d3a.tar.gz FreeFileSync-2a3ebac62eb6dd88122c0f447ea90ce368373d3a.tar.bz2 FreeFileSync-2a3ebac62eb6dd88122c0f447ea90ce368373d3a.zip |
1.18
Diffstat (limited to 'library/statistics.h')
-rw-r--r-- | library/statistics.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/library/statistics.h b/library/statistics.h new file mode 100644 index 00000000..3d4179db --- /dev/null +++ b/library/statistics.h @@ -0,0 +1,67 @@ +#ifndef STATISTICS_H_INCLUDED +#define STATISTICS_H_INCLUDED + +#include <vector> +#include <wx/stopwatch.h> +#include <list> + +class RetrieveStatistics +{ +public: + wxDEPRECATED(RetrieveStatistics() {}) //generate compiler warnings as a reminder to remove code after measurements + ~RetrieveStatistics(); + + void writeEntry(const double value, const int objects); + +private: + struct statEntry + { + long time; + int objects; + double value; + }; + + std::vector<statEntry> data; + wxStopWatch timer; +}; + + +class Statistics +{ +public: + Statistics(const int totalObjectCount, + const double totalDataAmount, + const unsigned windowSizeRemainingTime, //time in ms + const unsigned windowSizeBytesPerSecond); //time in ms + + void addMeasurement(const int objectsCurrent, const double dataCurrent); + wxString getRemainingTime() const; //returns the remaining time in milliseconds + wxString getBytesPerSecond() const; + + void pauseTimer(); + void resumeTimer(); + +private: + wxString formatRemainingTime(const double timeInMs) const; + + const int objectsTotal; + const double dataTotal; + + const unsigned windowSizeRemTime; //"window width" of statistics used for calculation of remaining time in ms + const unsigned windowSizeBPS; // + const unsigned windowMax; + + mutable int remainingTimeLast; //used for "smoothening" remaining time + + struct record + { + int objects; + double data; + long time; + }; + + std::list<record> measurements; + wxStopWatch timer; +}; + +#endif // STATISTICS_H_INCLUDED |