Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
profiling.h
Go to the documentation of this file.
1 
18 #ifndef ION_PROFILE_PROFILING_H_
19 #define ION_PROFILE_PROFILING_H_
20 
23 
27 
28 namespace ion {
29 namespace profile {
30 
32 ION_API CallTraceManager* GetCallTraceManager();
33 
34 } // namespace profile
35 } // namespace ion
36 
39 #define ION_PROFILING_PASTE1(x, y) x ## y
40 #define ION_PROFILING_PASTE2(x, y) ION_PROFILING_PASTE1(x, y)
41 #define ION_PROFILING_PASTE3(x) ION_PROFILING_PASTE2(x, __LINE__)
42 
47 #define ION_PROFILE_FUNCTION(func_name) \
48  /* Force compilation to fail if func_name is not a literal string */ \
49  (void) func_name " must be a literal string."; \
50  ION_DECLARE_SAFE_STATIC_POINTER_WITH_CONSTRUCTOR( \
51  int, ION_PROFILING_PASTE3(scope_event_id_), \
52  new int(::ion::profile::GetCallTraceManager()-> \
53  GetScopeEnterEvent(func_name))); \
54  DCHECK_NE(0, *ION_PROFILING_PASTE3(scope_event_id_)); \
55  ::ion::profile::ScopedTracer ION_PROFILING_PASTE3(scope_tracer_)( \
56  ::ion::profile::GetCallTraceManager()->GetTraceRecorder(), \
57  *ION_PROFILING_PASTE3(scope_event_id_));
58 
65 #define ION_PROFILE_FUNCTION_ANNOTATED(func_name, key, value) \
66  ION_PROFILE_FUNCTION(func_name); \
67  ::ion::profile::GetCallTraceManager()->GetTraceRecorder() \
68  ->AnnotateCurrentScope(key, value);
69 
70 #define ION_PROFILE_FRAME \
71  ION_DECLARE_SAFE_STATIC_POINTER_WITH_CONSTRUCTOR( \
72  int, ION_PROFILING_PASTE3(frame_number_), new int(0)); \
73  DCHECK_NE(0, ION_PROFILING_PASTE3(frame_number_)); \
74  ::ion::profile::ScopedFrameTracer ION_PROFILING_PASTE3(frame_tracer_)( \
75  ::ion::profile::GetCallTraceManager()->GetTraceRecorder(), \
76  ++(*ION_PROFILING_PASTE3(frame_number_)));
77 
78 #endif // ION_PROFILE_PROFILING_H_
CallTraceManager * GetCallTraceManager()
Get the global, static instance of CallTraceManager.
Definition: profiling.cc:25