00001 #ifndef MEPROFILE_H 00002 #define MEPROFILE_H 00003 00004 /* 00005 Copyright MathEngine PLC 1999 00006 00007 $Name$ 00008 00009 $Id$ 00010 */ 00011 00012 /** @file 00013 * Public profiling API 00014 */ 00015 00016 /** @mainpage 00017 * 00018 * @section overview Overview 00019 * 00020 * This library provides a variety of useful services: 00021 * 00022 * @arg Math helper functions. 00023 * @arg Profiling support. 00024 * @arg Simple cross platform file handling. 00025 * @arg Cross platform precision-related definitions. 00026 * 00027 */ 00028 #include "MePrecision.h" 00029 00030 #ifdef __cplusplus 00031 extern "C" { 00032 #endif 00033 00034 /** Profiling output styles */ 00035 typedef enum { 00036 kMeProfileOutputAverage, /**< A compact average display (default) */ 00037 kMeProfileOutputNormal, /**< Lists everything sequentially */ 00038 kMeProfileOutputGnuplot, /**< Produces several files in Gnuplot format */ 00039 } MeProfileOutput_enum; 00040 00041 typedef struct _MeProfileTimerResult { 00042 MeI64 cpuCycles; 00043 MeI64 count0; 00044 MeI64 count1; 00045 } MeProfileTimerResult; 00046 00047 /** Counter modes. These are only relevant for PS2 */ 00048 typedef enum { 00049 /** Counts floating point operations */ 00050 kMeProfileCounterModeFlops, 00051 /** Counts cache misses */ 00052 kMeProfileCounterModeCache 00053 } MeProfileCounterModes_enum; 00054 00055 /** Timer mode. These settings are only relevant for PS2 */ 00056 typedef struct { 00057 unsigned char granularity; /**< Granularity */ 00058 MeProfileCounterModes_enum counterMode; /**< Counter mode */ 00059 } MeProfileTimerMode; 00060 00061 /** Output style parameters */ 00062 typedef struct _MeProfileOutput { 00063 MeProfileOutput_enum style; /**< Output style */ 00064 float jaggedness; /**< For gnuplot */ 00065 unsigned char settletime; /**< For gnuplot */ 00066 } MeProfileOutput; 00067 00068 00069 /** Initialises profiling */ 00070 void MeProfileStartTiming(MeProfileTimerMode mode); 00071 00072 /** Cleans up profiling */ 00073 void MeProfileStopTiming(); 00074 00075 /** Indicates where in the code a frame is said to have started. */ 00076 void MeProfileStartFrame(); 00077 00078 /** Indicates that the end of a frame has been reached. */ 00079 void MeProfileEndFrame(); 00080 00081 /** Start timing a section of code. 00082 * @param codeSection Name of the section to be timed 00083 * @param autoStop If 1 then the timing of this section of code will 00084 * stop automatically at the next call to %MeProfileStartSection(). 00085 * If 0 then an explicit call to %MeProfileEndSection() will 00086 * have to be made. This allows for concurrent sections of 00087 * timed code. 00088 */ 00089 void MeProfileStartSection(const char* codeSection, unsigned char autoStop); 00090 00091 /** Explicitly stops timing the specified section of code. 00092 * You should not call this if you set autostop to 1 in MeProfileStartSection(). 00093 */ 00094 void MeProfileEndSection(const char* codeSection); 00095 00096 /** Can be called just before the end of a frame 00097 * to make sure all timers are stopped. 00098 */ 00099 void MeProfileStopTimers(); 00100 00101 /** Output profile results in the currently selected style. */ 00102 void MeProfileOutputResults(); 00103 00104 MeReal MeProfileGetSectionTime(const char* codeSection); 00105 00106 MeI64 MeProfileGetClockSpeed(); 00107 00108 /** Sets the ouput mode for profiling information. */ 00109 void MeProfileSetOutputParameters(MeProfileOutput output); 00110 00111 #if defined WIN32 00112 extern void MeProfileLimit(unsigned seconds); 00113 #endif 00114 00115 #ifdef __cplusplus 00116 } 00117 #endif 00118 00119 #endif /* MEPROFILE_H */
Copyright MathEngine PLC 2000, all rights reserved.