Profiler.h
Go to the documentation of this file.
00001 /* ========================================================================
00002 * PROJECT: ARToolKitPlus
00003 * ========================================================================
00004 * This work is based on the original ARToolKit developed by
00005 *   Hirokazu Kato
00006 *   Mark Billinghurst
00007 *   HITLab, University of Washington, Seattle
00008 * http://www.hitl.washington.edu/artoolkit/
00009 *
00010 * Copyright of the derived and new portions of this work
00011 *     (C) 2006 Graz University of Technology
00012 *
00013 * This framework is free software; you can redistribute it and/or modify
00014 * it under the terms of the GNU General Public License as published by
00015 * the Free Software Foundation; either version 2 of the License, or
00016 * (at your option) any later version.
00017 *
00018 * This framework is distributed in the hope that it will be useful,
00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 * GNU General Public License for more details.
00022 *
00023 * You should have received a copy of the GNU General Public License
00024 * along with this framework; if not, write to the Free Software
00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 *
00027 * For further information please contact 
00028 *   Dieter Schmalstieg
00029 *   <schmalstieg@icg.tu-graz.ac.at>
00030 *   Graz University of Technology, 
00031 *   Institut for Computer Graphics and Vision,
00032 *   Inffeldgasse 16a, 8010 Graz, Austria.
00033 * ========================================================================
00034 ** @author   Daniel Wagner
00035 *
00036 * $Id: Profiler.h 162 2006-04-19 21:28:10Z grabner $
00037 * @file
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 }  // namespace ARToolKitPlus
00108 
00109 
00110 //
00111 // we use macros to simplify calls to the profiler
00112 // and to turn profiling on/off
00113 // define _USE_PROFILING_ in the project settings
00114 // to activate profiling. note that this can reduce
00115 // overall performance a lot when used too deeply
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__


tuw_artoolkitplus
Author(s): Markus Bader
autogenerated on Sun May 29 2016 02:50:12