Ocular Engine
Profiler.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_CORE_PERFORMANCE_PROFILER__H__
19 #define __H__OCULAR_CORE_PERFORMANCE_PROFILER__H__
20 
21 #include "ProfilerNode.hpp"
22 #include "ProfilerScope.hpp"
23 
24 #include <sstream>
25 
26 //------------------------------------------------------------------------------------------
27 // Macros
28 //------------------------------------------------------------------------------------------
29 
30 //#define OCULAR_PERFORM_PROFILING
31 
32 #ifdef OCULAR_PERFORM_PROFILING
33 #define OCULAR_PROFILE() Ocular::Core::ProfilerScope OCULAR_INTERNAL_PROFILE_SCOPE(BOOST_CURRENT_FUNCTION);
34 #define OCULAR_PROFILE_START(x) OcularEngine.Profiler()->beginBlock(BOOST_CURRENT_FUNCTION, x);
35 #define OCULAR_PROFILE_STOP() OcularEngine.Profiler()->endBlock();
36 #else
37 #define OCULAR_PROFILE()
38 #define OCULAR_PROFILE_START(x) do { } while(false);
39 #define OCULAR_PROFILE_STOP()
40 #endif
41 
42 
43 //------------------------------------------------------------------------------------------
44 // Classes
45 //------------------------------------------------------------------------------------------
46 
51 namespace Ocular
52 {
57  namespace Core
58  {
128  class Profiler
129  {
130  public:
131 
132  Profiler();
133  ~Profiler();
134 
143  void beginBlock(std::string const& name, std::string const& segment);
144 
148  void endBlock();
149 
155  void printToConsole(bool prettify = true) const;
156 
163  void printToTXT(std::string const& path) const;
164 
170  void printToHTML(std::string const& path) const;
171 
172  protected:
173 
174  void destroy();
175  void destroyNode(ProfilerNode* node) const;
176 
177  void createLogBuffer(std::stringstream& stream, bool prettify) const;
178  void createLogForNode(ProfilerNode* node, std::stringstream& stream, bool prettify) const;
179 
180  std::string prettifyName(std::string const& name) const;
181 
182  private:
183 
184  ProfilerNode* m_RootNode;
185  ProfilerNode* m_CurrentNode;
186  };
187  }
191 }
196 //------------------------------------------------------------------------------------------
197 
198 #endif
void printToTXT(std::string const &path) const
Definition: Profiler.cpp:149
void endBlock()
Definition: Profiler.cpp:104
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
void printToConsole(bool prettify=true) const
Definition: Profiler.cpp:141
void printToHTML(std::string const &path) const
Definition: Profiler.cpp:164
std::string prettifyName(std::string const &name) const
Definition: Profiler.cpp:231
void beginBlock(std::string const &name, std::string const &segment)
Definition: Profiler.cpp:52
Definition: Profiler.hpp:128
Definition: ProfilerNode.hpp:39