1 #ifndef FILE_NG_PROFILER 2 #define FILE_NG_PROFILER 3 4 /**************************************************************************/ 5 /* File: profiler.hpp */ 6 /* Author: Joachim Schoeberl */ 7 /* Date: 5. Jan. 2005 */ 8 /**************************************************************************/ 9 10 11 12 #ifdef VTRACE 13 #include "vt_user.h" 14 #else 15 #define VT_USER_START(n) 16 #define VT_USER_END(n) 17 #define VT_TRACER(n) 18 #endif 19 20 namespace netgen 21 { 22 23 class NgProfiler 24 { 25 enum { SIZE = 1000 }; 26 27 static long int tottimes[SIZE]; 28 static long int starttimes[SIZE]; 29 static long int counts[SIZE]; 30 static string names[SIZE]; 31 static int usedcounter[SIZE]; 32 33 bool envNGPROFILE; 34 int total_timer; 35 36 public: 37 NgProfiler(); 38 ~NgProfiler(); 39 static int CreateTimer (const string & name); 40 StartTimer(int nr)41 static void StartTimer (int nr) 42 { 43 starttimes[nr] = clock(); counts[nr]++; 44 // VT_USER_START (const_cast<char*> (names[nr].c_str())); 45 VT_USER_START ( (char * const) (names[nr].c_str())); 46 } StopTimer(int nr)47 static void StopTimer (int nr) 48 { 49 tottimes[nr] += clock()-starttimes[nr]; 50 VT_USER_END (const_cast<char*> (names[nr].c_str())); 51 } 52 53 //static void Print (ostream & ost); 54 static void Print (FILE * prof); 55 56 class RegionTimer 57 { 58 int nr; 59 public: RegionTimer(int anr)60 RegionTimer (int anr) : nr(anr) 61 { StartTimer (nr); } ~RegionTimer()62 ~RegionTimer () { StopTimer (nr); } 63 }; 64 }; 65 66 } 67 68 #endif 69