a20b8d847bc14f2ac107129ab377bd1a95974393
[ipdf/code.git] / src / profiler.h
1 #ifndef _PROFILER_H
2 #define _PROFILER_H
3
4 #include <map>
5 #include <string>
6 #include <stack>
7
8 #define PROFILE_SCOPE(name) IPDF::ProfilerScope _localProfZone(name)
9
10 namespace IPDF
11 {
12         class Profiler
13         {
14         public:
15                 Profiler() {}
16                 
17                 void BeginZone(std::string name);
18                 void EndZone();
19
20                 void EndFrame();
21         private:
22                 struct ProfileZone
23                 {
24                         uint64_t tics_begin;
25                         uint64_t tics_end;
26                         uint64_t tics_frame;
27                         uint64_t tics_total;
28                         uint64_t calls_frame;
29                         uint64_t calls_total;
30                 };
31
32                 std::map<std::string, ProfileZone> m_zones;
33                 std::stack<std::string> m_zone_stack;
34         };
35
36         extern Profiler g_profiler;
37         struct ProfilerScope
38         {
39                 ProfilerScope(std::string name) { g_profiler.BeginZone(name); }
40                 ~ProfilerScope() { g_profiler.EndZone(); }
41         };
42
43 }
44
45 #endif

UCC git Repository :: git.ucc.asn.au