summaryrefslogtreecommitdiff
path: root/library/statistics.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 16:57:45 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 16:57:45 +0200
commit2a3ebac62eb6dd88122c0f447ea90ce368373d3a (patch)
treefae5c18deaecfb6f39d4d66dd3de8ce730b2025b /library/statistics.h
parent1.17 (diff)
downloadFreeFileSync-2a3ebac62eb6dd88122c0f447ea90ce368373d3a.tar.gz
FreeFileSync-2a3ebac62eb6dd88122c0f447ea90ce368373d3a.tar.bz2
FreeFileSync-2a3ebac62eb6dd88122c0f447ea90ce368373d3a.zip
1.18
Diffstat (limited to 'library/statistics.h')
-rw-r--r--library/statistics.h67
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
bgstack15