#include <profiler.h>
Classes | |
struct | AvgInfo |
Information maintained about averaged values. More... | |
struct | PerThread |
Information to be maintained for each thread. More... | |
class | ScopedBlock |
This instance will call Profiler::begin() when constructed and Profiler::end() when it goes out of scope. More... | |
class | ScopedStart |
This instance will call Profiler::start() when constructed and Profiler::stop() when it goes out of scope. If the profiler was already started, this block's constructor and destructor take no action. More... | |
struct | TimeInfo |
Information about time spent in a section of the code. More... | |
Public Member Functions | |
void | average (const std::string &name, const double value) |
Maintain the average of a specific value. | |
void | begin (const std::string &name) |
Begin counting time for a specific chunk of code. | |
void | clear (void) |
Clear counted time and events. | |
void | console (void) |
Print the status of the profiled code chunks and events to the console (using msg::Console) | |
void | end (const std::string &name) |
Stop counting time for a specific chunk of code. | |
void | event (const std::string &name, const unsigned int times=1) |
Count a specific event for a number of times. | |
Profiler (bool printOnDestroy=false, bool autoStart=false) | |
Constructor. It is allowed to separately instantiate this class (not only as a singleton) | |
bool | running (void) const |
Check if the profiler is counting time or not. | |
void | start (void) |
Start counting time. | |
void | status (std::ostream &out=std::cout, bool merge=true) |
Print the status of the profiled code chunks and events. Optionally, computation done by different threads can be printed separately. | |
void | stop (void) |
Stop counting time. | |
~Profiler (void) | |
Destructor. | |
Static Public Member Functions | |
static void | Average (const std::string &name, const double value) |
Maintain the average of a specific value. | |
static void | Begin (const std::string &name) |
Begin counting time for a specific chunk of code. | |
static void | Clear (void) |
Clear counted time and events. | |
static void | Console (void) |
Print the status of the profiled code chunks and events to the console (using msg::Console) | |
static void | End (const std::string &name) |
Stop counting time for a specific chunk of code. | |
static void | Event (const std::string &name, const unsigned int times=1) |
Count a specific event for a number of times. | |
static Profiler & | Instance (void) |
Return an instance of the class. | |
static bool | Running (void) |
Check if the profiler is counting time or not. | |
static void | Start (void) |
Start counting time. | |
static void | Status (std::ostream &out=std::cout, bool merge=true) |
Print the status of the profiled code chunks and events. Optionally, computation done by different threads can be printed separately. | |
static void | Stop (void) |
Stop counting time. | |
Private Member Functions | |
void | printThreadInfo (std::ostream &out, const PerThread &data) |
Private Attributes | |
std::map< boost::thread::id, PerThread > | data_ |
boost::mutex | lock_ |
bool | printOnDestroy_ |
bool | running_ |
TimeInfo | tinfo_ |
This is a simple thread-safe tool for counting time spent in various chunks of code. This is different from external profiling tools in that it allows the user to count time spent in various bits of code (sub-function granularity) or count how many times certain pieces of code are executed.
Definition at line 73 of file profiler.h.
moveit::Profiler::Profiler | ( | bool | printOnDestroy = false , |
bool | autoStart = false |
||
) | [inline] |
Constructor. It is allowed to separately instantiate this class (not only as a singleton)
Definition at line 128 of file profiler.h.
moveit::Profiler::~Profiler | ( | void | ) | [inline] |
Destructor.
Definition at line 135 of file profiler.h.
static void moveit::Profiler::Average | ( | const std::string & | name, |
const double | value | ||
) | [inline, static] |
Maintain the average of a specific value.
Definition at line 178 of file profiler.h.
void moveit::Profiler::average | ( | const std::string & | name, |
const double | value | ||
) |
Maintain the average of a specific value.
static void moveit::Profiler::Begin | ( | const std::string & | name | ) | [inline, static] |
Begin counting time for a specific chunk of code.
Definition at line 187 of file profiler.h.
void moveit::Profiler::begin | ( | const std::string & | name | ) |
Begin counting time for a specific chunk of code.
static void moveit::Profiler::Clear | ( | void | ) | [inline, static] |
Clear counted time and events.
Definition at line 154 of file profiler.h.
void moveit::Profiler::clear | ( | void | ) |
Clear counted time and events.
static void moveit::Profiler::Console | ( | void | ) | [inline, static] |
Print the status of the profiled code chunks and events to the console (using msg::Console)
Definition at line 219 of file profiler.h.
void moveit::Profiler::console | ( | void | ) |
Print the status of the profiled code chunks and events to the console (using msg::Console)
static void moveit::Profiler::End | ( | const std::string & | name | ) | [inline, static] |
Stop counting time for a specific chunk of code.
Definition at line 193 of file profiler.h.
void moveit::Profiler::end | ( | const std::string & | name | ) |
Stop counting time for a specific chunk of code.
static void moveit::Profiler::Event | ( | const std::string & | name, |
const unsigned int | times = 1 |
||
) | [inline, static] |
Count a specific event for a number of times.
Definition at line 169 of file profiler.h.
void moveit::Profiler::event | ( | const std::string & | name, |
const unsigned int | times = 1 |
||
) |
Count a specific event for a number of times.
moveit::Profiler & moveit::Profiler::Instance | ( | void | ) | [static] |
void moveit::Profiler::printThreadInfo | ( | std::ostream & | out, |
const PerThread & | data | ||
) | [private] |
bool moveit::Profiler::running | ( | void | ) | const [inline] |
Check if the profiler is counting time or not.
Definition at line 229 of file profiler.h.
static bool moveit::Profiler::Running | ( | void | ) | [inline, static] |
Check if the profiler is counting time or not.
Definition at line 235 of file profiler.h.
static void moveit::Profiler::Start | ( | void | ) | [inline, static] |
Start counting time.
Definition at line 142 of file profiler.h.
void moveit::Profiler::start | ( | void | ) |
Start counting time.
static void moveit::Profiler::Status | ( | std::ostream & | out = std::cout , |
bool | merge = true |
||
) | [inline, static] |
Print the status of the profiled code chunks and events. Optionally, computation done by different threads can be printed separately.
Definition at line 207 of file profiler.h.
void moveit::Profiler::status | ( | std::ostream & | out = std::cout , |
bool | merge = true |
||
) |
Print the status of the profiled code chunks and events. Optionally, computation done by different threads can be printed separately.
static void moveit::Profiler::Stop | ( | void | ) | [inline, static] |
Stop counting time.
Definition at line 148 of file profiler.h.
void moveit::Profiler::stop | ( | void | ) |
Stop counting time.
std::map<boost::thread::id, PerThread> moveit::Profiler::data_ [private] |
Definition at line 312 of file profiler.h.
boost::mutex moveit::Profiler::lock_ [private] |
Definition at line 311 of file profiler.h.
bool moveit::Profiler::printOnDestroy_ [private] |
Definition at line 315 of file profiler.h.
bool moveit::Profiler::running_ [private] |
Definition at line 314 of file profiler.h.
TimeInfo moveit::Profiler::tinfo_ [private] |
Definition at line 313 of file profiler.h.