Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _CHRONO_HXX_
00021 #define _CHRONO_HXX_
00022
00023 #include <vector>
00024 #include <string>
00025 #include <iostream>
00026 #include <ctime>
00027
00028 typedef struct acnt
00029 {
00030 char* _ctrNames;
00031 int _ctrLines;
00032 int _ctrOccur;
00033 double _ctrCumul;
00034 } cntStruct;
00035
00036 class counters
00037 {
00038 public:
00039 static cntStruct *_ctrs;
00040 counters(int nb);
00041 ~counters();
00042 static void stats();
00043 protected:
00044 static int _nbChrono;
00045 };
00046
00047 class chrono
00048 {
00049 public:
00050 chrono(int i);
00051 ~chrono();
00052 void stop();
00053 protected:
00054 bool _run;
00055 int _ctr;
00056 clock_t _start, _end;
00057 };
00058
00059 #ifdef CHRONODEF
00060 #define CHRONO(i) counters::_ctrs[i]._ctrNames = (char *)__FILE__; \
00061 counters::_ctrs[i]._ctrLines = __LINE__; \
00062 chrono aChrono##i(i);
00063
00064 #define CHRONOSTOP(i) aChrono##i.stop();
00065
00066 #else // CHRONODEF
00067
00068 #define CHRONO(i)
00069 #define CHRONOSTOP(i)
00070
00071 #endif // CHRONODEF
00072
00073 #endif // _CHRONO_HXX_