profiler.h

Go to the documentation of this file.
00001 #ifndef __PROFILER_H__
00002 #define __PROFILER_H__
00003 
00004 /*
00005  Copyright (c) 2006-2010 Trevor Williams
00006 
00007  This program is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU General Public License as published by the Free Software
00009  Foundation; either version 2 of the License, or (at your option) any later version.
00010 
00011  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
00012  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00013  See the GNU General Public License for more details.
00014 
00015  You should have received a copy of the GNU General Public License along with this program;
00016  if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00025 #include "defines.h"
00026 #include "genprof.h"
00027 #include "util.h"
00028 
00029 
00030 #define PROFILE(index) int foobar
00031 //#define PROFILE(index)
00032 #define PROFILE_START(index)
00033 #define PROFILE_END    foobar = 0
00034 //#define PROFILE_END
00035 #define MALLOC_CALL(index)
00036 #define FREE_CALL(index)
00037 
00038 #ifdef PROFILER
00039 #ifdef HAVE_SYS_TIME_H
00040 
00041 #undef PROFILE
00042 #undef PROFILE_START
00043 #undef PROFILE_END
00044 #undef MALLOC_CALL
00045 #undef FREE_CALL
00046 
00047 #define PROFILE(index)     unsigned int profile_index = index;  if(profiling_mode) profiler_enter(index);
00048 #define PROFILE_END        if(profiling_mode) profiler_exit(profile_index);
00049 #define MALLOC_CALL(index) if(profiling_mode) profiles[index].mallocs++;
00050 #define FREE_CALL(index)   if(profiling_mode) profiles[index].frees++;
00051 
00052 #endif
00053 #endif
00054 
00055 
00056 /*@-exportlocal@*/
00057 extern bool profiling_mode;
00058 /*@=exportlocal@*/
00059 
00060 
00062 void profiler_set_mode( bool value );
00063 
00065 void profiler_set_filename( const char* fname );
00066 
00068 void profiler_enter( unsigned int index );
00069 
00071 void profiler_exit( unsigned int index );
00072 
00074 void profiler_report();
00075 
00076 #endif
00077 
Generated on Sun Nov 21 00:55:35 2010 for Covered by  doxygen 1.6.3