lugre_profile.h

Go to the documentation of this file.
00001 /*
00002 http://www.opensource.org/licenses/mit-license.php  (MIT-License)
00003 
00004 Copyright (c) 2007 Lugre-Team
00005 
00006 Permission is hereby granted, free of charge, to any person obtaining a copy
00007 of this software and associated documentation files (the "Software"), to deal
00008 in the Software without restriction, including without limitation the rights
00009 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010 copies of the Software, and to permit persons to whom the Software is
00011 furnished to do so, subject to the following conditions:
00012 
00013 The above copyright notice and this permission notice shall be included in
00014 all copies or substantial portions of the Software.
00015 
00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00019 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00020 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00021 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00022 THE SOFTWARE.
00023 */
00024 #ifndef LUGRE_PROFILE_H
00025 #define LUGRE_PROFILE_H
00026 
00027 namespace Lugre {
00028 #define ENABLE_PROFILING
00029 
00030 #ifdef ENABLE_PROFILING
00031     // for calltime and callcount profiling and runtime callstacks/backtraces
00032         
00033     class cProfiler { public:
00034         cProfiler(const char* sFile,const int iLine,const char* sFunc); // save current time
00035         ~cProfiler(); // calc time since constructor
00036         
00037         static void     PrintStackTrace ();
00038         static void     PrintStackTrace (const char *filename);
00039     };
00040     
00042     #define PROFILE     cProfiler local_profiler(__FILE__,__LINE__,__FUNCTION__);
00043     #define PROFILEH PROFILE    //  enable profiling of heavy duty functions
00044     #define PROFILE_PRINT_STACKTRACE cProfiler::PrintStackTrace();
00045     #define PROFILE_PRINT_STACKTRACE_TOFILE(filename) cProfiler::PrintStackTrace(filename);
00046 #else 
00047     #define PROFILE 
00048     #define PROFILEH PROFILE
00049     #define PROFILE_HEAVY PROFILE
00050     #define PROFILE_PRINT_STACKTRACE
00051     #define PROFILE_PRINT_STACKTRACE_TOFILE(filename)
00052 #endif
00053 
00055 #ifndef PROFILEH
00056     #define PROFILEH
00057 #endif
00058 };  
00059     
00060 #endif

Generated on Wed Feb 8 06:00:12 2012 for cpp by  doxygen 1.5.6