CACAO
Files | Macros
Real-time timing framework

Real-time timing framework. More...

Files

file  rt-timing.hpp
 This file contains the real-time timing utilities.
 

Macros

#define RT_REGISTER_TIMER(var, name, description)
 Register a new (toplevel) timer. More...
 
#define RT_REGISTER_GROUP_TIMER(var, name, description, group)
 Register a new timer. More...
 
#define RT_REGISTER_GROUP(var, name, description)
 Register a new (toplevel) group. More...
 
#define RT_REGISTER_SUBGROUP(var, name, description, group)
 Register a new subgroup. More...
 
#define RT_REGISTER_TIMER_EXTERN(var, name, description)
 Define external timer. More...
 
#define RT_REGISTER_GROUP_TIMER_EXTERN(var, name, description, group)
 Define external group timer. More...
 
#define RT_REGISTER_GROUP_EXTERN(var, name, description)
 Define external group. More...
 
#define RT_REGISTER_SUBGROUP_EXTERN(var, name, description, group)
 Define external subgroup. More...
 
#define RT_DECLARE_TIMER(var)
 Declare an external timer variable. More...
 
#define RT_DECLARE_GROUP(var)
 Declare an external timer group. More...
 
#define RT_TIMER_START(var)
 Start the timer var. More...
 
#define RT_TIMER_STOP(var)
 Stop the timer var. More...
 
#define RT_TIMER_STOPSTART(var1, var2)
 Stop the timer var1 and start the timer var2. More...
 

Detailed Description

Real-time timing framework.

For day to day use only the following macros are of importance:

A typical usage would look something like this:

* // NOTE: toplevel, outside a function!
* RT_REGISTER_GROUP(my_group,"my-group","this is my very own timing group");
* RT_REGISTER_GROUP_TIMER(my_timer1,"my-timer1","this is my first timer",my_group);
* RT_REGISTER_GROUP_TIMER(my_timer2,"my-timer1","this is my second timer",my_group);
*
* void do_something() {
* RT_TIMER_START(my_timer1);
* // do some work
* RT_TIMER_STOPSTART(my_timer1,my_timer2);
* // do even more work
* RT_TIMER_STOP(my_timer2);
* }
*
Note
The implementation of the RT_REGISTER_* macros is a bit tricky. In general we simply want to create global variables for groups and timers. Unfortunately RTGroup and RTTimer are no "plain old datatypes" (pod). There is a constructor which is dependant on other global non-pod variables. The C++ standard does not guarantee any specific order of construction so it might be the case that a subgroup is registered before its super group. There are many dirty tricks to work around this issue. The one we are using does the following. We create a global variable as well as a function which returns this variable. The C++ standard guarantees that a global variable is initialized before its first use. Therefore, if we access the group/timer variables only through these functions it is guaranteed that everything is initialized in the right order. Also note that the variable must be global (i.e. they can not be declared as static function variables) otherwise the objects might be destroyed eagerly.

Macro Definition Documentation

#define RT_DECLARE_GROUP (   var)

Declare an external timer group.

See Also
RT_REGISTER_GROUP_EXTERN
RT_REGISTER_SUBGROUP_EXTERN

Definition at line 692 of file rt-timing.hpp.

#define RT_DECLARE_TIMER (   var)

Declare an external timer variable.

See Also
RT_REGISTER_TIMER_EXTERN
RT_REGISTER_GROUP_TIMER_EXTERN

Definition at line 691 of file rt-timing.hpp.

#define RT_REGISTER_GROUP (   var,
  name,
  description 
)

Register a new (toplevel) group.

Create a group and add it to the toplevel timing group RTGroup::root().

Note
This macro creates a function RTGroup& var(). Consider using namespaces to avoid name clashes.

Definition at line 683 of file rt-timing.hpp.

#define RT_REGISTER_GROUP_EXTERN (   var,
  name,
  description 
)

Define external group.

See Also
RT_REGISTER_GROUP
RT_DECLARE_GROUP

Definition at line 688 of file rt-timing.hpp.

#define RT_REGISTER_GROUP_TIMER (   var,
  name,
  description,
  group 
)

Register a new timer.

Create a timer and add it to group specified.

Note
This macro creates a function RTTimer& var(). Consider using namespaces to avoid name clashes.

Definition at line 682 of file rt-timing.hpp.

#define RT_REGISTER_GROUP_TIMER_EXTERN (   var,
  name,
  description,
  group 
)

Define external group timer.

See Also
RT_REGISTER_GROUP_TIMER
RT_DECLARE_TIMER

Definition at line 687 of file rt-timing.hpp.

#define RT_REGISTER_SUBGROUP (   var,
  name,
  description,
  group 
)

Register a new subgroup.

Create a group and add it to group specified.

Note
This macro creates a function RTGroup& var(). Consider using namespaces to avoid name clashes.

Definition at line 684 of file rt-timing.hpp.

#define RT_REGISTER_SUBGROUP_EXTERN (   var,
  name,
  description,
  group 
)

Define external subgroup.

See Also
RT_REGISTER_SUBGROUP
RT_DECLARE_GROUP

Definition at line 689 of file rt-timing.hpp.

#define RT_REGISTER_TIMER (   var,
  name,
  description 
)

Register a new (toplevel) timer.

Create a timer and add it to the toplevel timing group RTGroup::root().

Note
This macro creates a function RTTimer& var(). Consider using namespaces to avoid name clashes.

Definition at line 681 of file rt-timing.hpp.

#define RT_REGISTER_TIMER_EXTERN (   var,
  name,
  description 
)

Define external timer.

See Also
RT_REGISTER_TIMER
RT_DECLARE_TIMER

Definition at line 686 of file rt-timing.hpp.

#define RT_TIMER_START (   var)

Start the timer var.

Definition at line 694 of file rt-timing.hpp.

#define RT_TIMER_STOP (   var)

Stop the timer var.

Definition at line 695 of file rt-timing.hpp.

#define RT_TIMER_STOPSTART (   var1,
  var2 
)

Stop the timer var1 and start the timer var2.

Definition at line 696 of file rt-timing.hpp.