mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-26 21:00:34 +05:00
optional use of tsc-counter
This commit is contained in:
parent
786acf0388
commit
5dc501af26
@ -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
|
||||
|
@ -17,6 +17,12 @@
|
||||
#define VT_TRACER(n)
|
||||
#endif
|
||||
|
||||
|
||||
// #define USE_TSC
|
||||
#ifdef USE_TSC
|
||||
#include <x86intrin.h> // 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<char*> (names[nr].c_str()));
|
||||
}
|
||||
|
||||
#else
|
||||
static void StartTimer (int nr)
|
||||
{
|
||||
starttimes[nr] = __rdtsc(); counts[nr]++;
|
||||
// VT_USER_START (const_cast<char*> (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<char*> (names[nr].c_str()));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//static void Print (ostream & ost);
|
||||
static void Print (FILE * prof);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user