GComm  0.2.3
Classes | Macros | Functions
profile.hpp File Reference

Lightweight profiling utility. More...

#include "gu_time.h"
#include <map>
#include <ostream>

Go to the source code of this file.

Classes

class  prof::Key
 
class  prof::Point
 
class  prof::Profile
 

Macros

#define profile_enter(__p)
 
#define profile_leave(__p)
 

Functions

std::ostream & prof::operator<< (std::ostream &, const Key &)
 
std::ostream & prof::operator<< (std::ostream &, const Profile &)
 

Detailed Description

Lightweight profiling utility.

Profiling utility suitable for getting runtime code profile information with minimal overhead. Macros profile_enter() and profile_leave() can be inserted around the code and will be expanded to profiling code if GCOMM_PROFILE is defined.

Example usage:

Profile prof("prof");
void func()
{
if (is_true())
{
profile_enter(prof); // This is line 227
// Do something
// ...
profile_leave(prof);
}
else
{
profile_enter(prof); // This is line 250
// Do something else
// ...
profile_leave(prof);
}
}
// Somewhere else in your code
log_info << prof;