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
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef __ARTOOLKITPLUS_PROFILER_HEADERFILE__
00042 #define __ARTOOLKITPLUS_PROFILER_HEADERFILE__
00043
00044
00045 #if defined(WIN32) || defined(_WIN32_WCE)
00046 # define _ARTKP_IS_WINDOWS_
00047 #endif
00048
00049
00050 #ifdef _ARTKP_IS_WINDOWS_
00051 # include <windows.h>
00052 #endif
00053
00054
00055 namespace ARToolKitPlus {
00056
00057
00058 class Profiler
00059 {
00060 public:
00061 enum MES {
00062 SINGLEMARKER_OVERALL,
00063 LABELING,
00064 DETECTMARKER2,
00065 GETMARKERINFO,
00066
00067 GETTRANSMAT,
00068 GETINITROT,
00069 GETTRANSMAT3,
00070 GETTRANSMATSUB,
00071 MODIFYMATRIX_LOOP,
00072 MODIFYMATRIX,
00073 GETNEWMATRIX,
00074 GETROT,
00075
00076 GETANGLE
00077 };
00078
00079 struct Measurement {
00080 #ifdef _ARTKP_IS_WINDOWS_
00081 LARGE_INTEGER secBegin, secEnd, sum;
00082 #endif
00083 void reset();
00084 };
00085
00086 Measurement _SINGLEMARKER_OVERALL, _LABELING, _DETECTMARKER2, _GETMARKERINFO, _GETTRANSMAT,
00087 _GETINITROT, _GETTRANSMAT3, _GETTRANSMATSUB, _MODIFYMATRIX_LOOP, _MODIFYMATRIX, _GETNEWMATRIX,
00088 _GETROT, _GETANGLE;
00089
00090 void reset();
00091 void beginSection(Measurement& nM);
00092 void endSection(Measurement& nM);
00093
00094 float getFraction(const Measurement& nNom, const Measurement& nDenom) const;
00095 float getFraction(MES nNom, MES nDenom) const;
00096 float getTime(MES nMes) const;
00097
00098 void writeReport(const char* nFileName, unsigned int nNumRuns=1) const;
00099
00100 static bool isProfilingEnabled();
00101
00102 protected:
00103 const Measurement* getMes(MES nMes) const;
00104 };
00105
00106
00107 }
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 #ifdef _USE_PROFILING_
00118 #define PROFILE_BEGINSEC(obj, mes) obj.beginSection(obj._##mes);
00119 #define PROFILE_ENDSEC(obj, mes) obj.endSection(obj._##mes);
00120
00121 #define PROFILEPTR_BEGINSEC(obj, mes) if(obj) obj->beginSection(obj->_##mes);
00122 #define PROFILEPTR_ENDSEC(obj, mes) if(obj) obj->endSection(obj->_##mes);
00123 #else
00124 #define PROFILE_BEGINSEC(obj, mes);
00125 #define PROFILE_ENDSEC(obj, mes);
00126
00127 #define PROFILEPTR_BEGINSEC(obj, mes)
00128 #define PROFILEPTR_ENDSEC(obj, mes)
00129 #endif //_USE_PROFILING_
00130
00131
00132 #endif //__ARTOOLKITPLUS_PROFILER_HEADERFILE__