X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fprofiler.h;fp=src%2Fprofiler.h;h=a20b8d847bc14f2ac107129ab377bd1a95974393;hp=0000000000000000000000000000000000000000;hb=a8297c3461718f2d9afc7a2f8ca620d320ac5f97;hpb=667281b828c8515e995c0000706157cee180fa08 diff --git a/src/profiler.h b/src/profiler.h new file mode 100644 index 0000000..a20b8d8 --- /dev/null +++ b/src/profiler.h @@ -0,0 +1,45 @@ +#ifndef _PROFILER_H +#define _PROFILER_H + +#include +#include +#include + +#define PROFILE_SCOPE(name) IPDF::ProfilerScope _localProfZone(name) + +namespace IPDF +{ + class Profiler + { + public: + Profiler() {} + + void BeginZone(std::string name); + void EndZone(); + + void EndFrame(); + private: + struct ProfileZone + { + uint64_t tics_begin; + uint64_t tics_end; + uint64_t tics_frame; + uint64_t tics_total; + uint64_t calls_frame; + uint64_t calls_total; + }; + + std::map m_zones; + std::stack m_zone_stack; + }; + + extern Profiler g_profiler; + struct ProfilerScope + { + ProfilerScope(std::string name) { g_profiler.BeginZone(name); } + ~ProfilerScope() { g_profiler.EndZone(); } + }; + +} + +#endif