profiler.h
Go to the documentation of this file.00001 #ifndef __PROFILER_H__
00002 #define __PROFILER_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00025 #include "defines.h"
00026 #include "genprof.h"
00027 #include "util.h"
00028
00029
00030 #define PROFILE(index) int foobar
00031
00032 #define PROFILE_START(index)
00033 #define PROFILE_END foobar = 0
00034
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
00057 extern bool profiling_mode;
00058
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