00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef LUX_STATS_H
00024 #define LUX_STATS_H
00025
00026
00027
00028 #include "lux.h"
00029
00030 namespace lux
00031 {
00032 void StatsPrint(FILE *dest);
00033 void StatsCleanup();
00034 }
00035
00036 class ProgressReporter {
00037 public:
00038
00039 ProgressReporter(int totalWork, const string &title, int barLength=58);
00040 ~ProgressReporter();
00041 void Update(int num = 1) const;
00042 void Done() const;
00043
00044 const int totalPlusses;
00045 float frequency;
00046 mutable float count;
00047 mutable int plussesPrinted;
00048 mutable Timer *timer;
00049 FILE *outFile;
00050 char *buf;
00051 mutable char *curSpace;
00052 };
00053 class StatsCounter {
00054 public:
00055
00056 StatsCounter(const string &category, const string &name);
00057 void operator++() { ++num; }
00058 void operator++(int) { ++num; }
00059 void Max(StatsCounterType val) { num = max(val, num); }
00060 void Min(StatsCounterType val) { num = min(val, num); }
00061 operator double() const { return (double)num; }
00062 private:
00063
00064 StatsCounterType num;
00065 };
00066 class StatsRatio {
00067 public:
00068
00069 StatsRatio(const string &category, const string &name);
00070 void Add(int a, int b) { na += a; nb += b; }
00071 private:
00072
00073 StatsCounterType na, nb;
00074 };
00075 class StatsPercentage {
00076 public:
00077
00078 void Add(int a, int b) { na += a; nb += b; }
00079 StatsPercentage(const string &category, const string &name);
00080 private:
00081
00082 StatsCounterType na, nb;
00083 };
00084
00085 #endif // LUX_STATS_H
00086