XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
timer_macro.hpp
Go to the documentation of this file.
1 #ifndef TIMER_MACRO_HPP
2 #define TIMER_MACRO_HPP
3 
4 #ifdef CAM_TIMERS
5 #include "gptl.h"
6 #else
7 // If camtimers is not present, use this spoofed version of the timers
8 static int GPTLinitialize(){ return 0;}
9 static int GPTLstart(const char* name){ return 0;}
10 static int GPTLstop(const char* name){ return 0;}
11 static int GPTLpr_file(const char* name){ return 0;}
12 #endif
13 
14 // Since it's a common name, make sure it isn't already used somewhere
15 #ifdef TIMER
16 #error "TIMER macro already defined"
17 #endif
18 
19 #define TIMER(N,F) {GPTLstart(N); F; GPTLstop(N);}
20 // e.g.: TIMER(push(), "Push");
21 // becomes:
22 // {
23 // GPTLstart("Push");
24 // push();
25 // GPTLstop("Push");
26 // }
27 //
28 // The braces are there for safe scoping, but that means you can't time declarations. Here is an non-scoped version:
29 
30 #ifdef TIMER_NS
31 #error "TIMER_NS macro already defined"
32 #endif
33 
34 #define TIMER_NS(N,F) GPTLstart(N); F; GPTLstop(N);
35 
36 
37 #endif
static int GPTLstart(const char *name)
Definition: timer_macro.hpp:9
static int GPTLinitialize()
Definition: timer_macro.hpp:8
static int GPTLpr_file(const char *name)
Definition: timer_macro.hpp:11
static int GPTLstop(const char *name)
Definition: timer_macro.hpp:10