/opt/ros/diamondback/stacks/graspit_simulator/graspit/graspit_source/include/profiling.h File Reference

#include <iostream>
#include <vector>
#include <string>
#include "assert.h"
#include "timer_calls.h"
#include <sys/time.h>
#include <sys/types.h>
Include dependency graph for profiling.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Profiling::FunctionTimer
class  Profiling::ProfileInstance
class  Profiling::Profiler

Namespaces

namespace  Profiling

Defines

#define PROF_COUNT(STR)   ;
#define PROF_DECLARE(STR)   ;
#define PROF_EXTERN(STR)   ;
#define PROF_PRINT(STR)   ;
#define PROF_PRINT_ALL   ;
#define PROF_RESET(STR)   ;
#define PROF_RESET_ALL   ;
#define PROF_START_TIMER(STR)   ;
#define PROF_STOP_TIMER(STR)   ;
#define PROF_TIMER_FUNC(STR)   ;

Functions

Profiler & Profiling::getProfiler ()

Detailed Description

Implements a number of tools for simple, but easy to use and efficient code profiling. It should add a tiny overhead to the caller code, so it can be called lots of times.

Usage example: ---------------------------- define PROF_ENABLED include "profiling.h"

PROF_DECLARE(TOTAL_TIMER); PROF_DECLARE(FOO_TIMER);

void foo() { PROF_TIMER_FUNC(FOO_TIMER); for (int i=0; i<1000; i++) {} }

int main(int, char**) {

PROF_START_TIMER(TOTAL_TIMER); for (int i=0; i<100000; i++) { for (int j=0; j<2000; j++) {} foo(); } PROF_STOP_TIMER(TOTAL_TIMER);

Total time in program PROF_PRINT(TOTAL_TIMER); Number of calls to and time spent in foo() function PROF_PRINT(FOO_TIMER);

return 0; } -------------------------------

Usage "manual":

The main concept is a "timer", of which you can define as many as you want. When you define a timer, you associate a name with it, and then you can start it, stop it, print it, or have it time a particular function. Any timer will also double as a counter, and you can reset or increment its count whenever you want.

To declare a new timer, use:

PROF_DECLARE(my_timer_name);

This can be placed in any source file in your project. Just be sure to place timer declarations at the global scope (not inside of any functions). Don't worry about namespace pollution, everything profiler-related ends up in its own namespace behind the scenes.

The name then becomes the unique identifier that you can refer to a timer through. The main feature of this framework is that you can use literal names, thus making it easy to use. However, behind the scenes they are converted into static ints and add no overhead when they need to be matched against timers. On the other hand, using any undeclared timer is caught at compile-time.

To use the same timer in a different file than it was declared in, place an extern declaration in the file you use it in:

PROF_EXTERN(my_timer_name);

See below macros for what you can do with a timer.

Definition in file profiling.h.


Define Documentation

#define PROF_COUNT ( STR   )     ;

Definition at line 155 of file profiling.h.

#define PROF_DECLARE ( STR   )     ;

Definition at line 151 of file profiling.h.

#define PROF_EXTERN ( STR   )     ;

Definition at line 152 of file profiling.h.

#define PROF_PRINT ( STR   )     ;

Definition at line 159 of file profiling.h.

#define PROF_PRINT_ALL   ;

Definition at line 160 of file profiling.h.

#define PROF_RESET ( STR   )     ;

Definition at line 153 of file profiling.h.

#define PROF_RESET_ALL   ;

Definition at line 154 of file profiling.h.

#define PROF_START_TIMER ( STR   )     ;

Definition at line 156 of file profiling.h.

#define PROF_STOP_TIMER ( STR   )     ;

Definition at line 157 of file profiling.h.

#define PROF_TIMER_FUNC ( STR   )     ;

Definition at line 158 of file profiling.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


graspit
Author(s):
autogenerated on Wed Jan 25 10:59:17 2012