diff --git a/libsrc/general/profiler.cpp b/libsrc/general/profiler.cpp index 06ea6934..e6a9685b 100644 --- a/libsrc/general/profiler.cpp +++ b/libsrc/general/profiler.cpp @@ -88,7 +88,11 @@ namespace netgen if (counts[i] != 0 || usedcounter[i] != 0) { //fprintf(prof,"job %3i calls %8i, time %6.2f sec",i,counts[i],double(tottimes[i]) / CLOCKS_PER_SEC); - fprintf(prof,"calls %8li, time %6.2f sec",counts[i],double(tottimes[i]) / CLOCKS_PER_SEC); +#ifndef USE_TSC + fprintf(prof,"calls %8li, time %6.2f sec",counts[i],double(tottimes[i]) / CLOCKS_PER_SEC); +#else + fprintf(prof,"calls %8li, time %6.2f sec",counts[i],double(tottimes[i]) / 2.7e9); +#endif if(usedcounter[i]) fprintf(prof," %s",names[i].c_str()); else diff --git a/libsrc/general/profiler.hpp b/libsrc/general/profiler.hpp index c39a5fbc..98039114 100644 --- a/libsrc/general/profiler.hpp +++ b/libsrc/general/profiler.hpp @@ -17,6 +17,12 @@ #define VT_TRACER(n) #endif + +// #define USE_TSC +#ifdef USE_TSC +#include // for __rdtsc() CPU time step counter +#endif + namespace netgen { @@ -35,7 +41,7 @@ public: NgProfiler(); ~NgProfiler(); static int CreateTimer (const string & name); - +#ifndef USE_TSC static void StartTimer (int nr) { starttimes[nr] = clock(); counts[nr]++; @@ -47,7 +53,21 @@ public: tottimes[nr] += clock()-starttimes[nr]; VT_USER_END (const_cast (names[nr].c_str())); } - +#else + static void StartTimer (int nr) + { + starttimes[nr] = __rdtsc(); counts[nr]++; + // VT_USER_START (const_cast (names[nr].c_str())); + // VT_USER_START ( (char * const) (names[nr].c_str())); + } + static void StopTimer (int nr) + { + tottimes[nr] += __rdtsc()-starttimes[nr]; + VT_USER_END (const_cast (names[nr].c_str())); + } +#endif + + //static void Print (ostream & ost); static void Print (FILE * prof);