Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/netgen/libsrc/general/profiler.hpp
3206 views
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
21
22
class NgProfiler
23
{
24
enum { SIZE = 1000 };
25
26
static long int tottimes[SIZE];
27
static long int starttimes[SIZE];
28
static long int counts[SIZE];
29
static string names[SIZE];
30
static int usedcounter[SIZE];
31
32
int total_timer;
33
public:
34
NgProfiler();
35
~NgProfiler();
36
static int CreateTimer (const string & name);
37
38
static void StartTimer (int nr)
39
{
40
starttimes[nr] = clock(); counts[nr]++;
41
VT_USER_START (const_cast<char*> (names[nr].c_str()));
42
}
43
static void StopTimer (int nr)
44
{
45
tottimes[nr] += clock()-starttimes[nr];
46
VT_USER_END (const_cast<char*> (names[nr].c_str()));
47
}
48
49
//static void Print (ostream & ost);
50
static void Print (FILE * prof);
51
52
class RegionTimer
53
{
54
int nr;
55
public:
56
RegionTimer (int anr) : nr(anr)
57
{ StartTimer (nr); }
58
~RegionTimer () { StopTimer (nr); }
59
};
60
};
61
62
#endif
63
64