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. More...
#include <Profiler.h>
Classes | |
class | BeginBlock |
This instance will call Profiler::begin() when constructed and Profiler::end() when it goes out of scope. More... | |
struct | PerThread |
Timing information to be maintained for each thread. More... | |
struct | TimeInfo |
Information about time spent in a section of the code. More... | |
Public Member Functions | |
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). | |
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 | 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 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 75 of file Profiler.h.
ompl::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 105 of file Profiler.h.
ompl::Profiler::~Profiler | ( | void | ) | [inline] |
Destructor.
Definition at line 112 of file Profiler.h.
void ompl::Profiler::begin | ( | const std::string & | name | ) |
Begin counting time for a specific chunk of code.
static void ompl::Profiler::Begin | ( | const std::string & | name | ) | [inline, static] |
Begin counting time for a specific chunk of code.
Definition at line 155 of file Profiler.h.
void ompl::Profiler::clear | ( | void | ) |
Clear counted time and events.
static void ompl::Profiler::Clear | ( | void | ) | [inline, static] |
Clear counted time and events.
Definition at line 131 of file Profiler.h.
void ompl::Profiler::console | ( | void | ) |
Print the status of the profiled code chunks and events to the console (using msg::Console).
static void ompl::Profiler::Console | ( | void | ) | [inline, static] |
Print the status of the profiled code chunks and events to the console (using msg::Console).
Definition at line 187 of file Profiler.h.
void ompl::Profiler::end | ( | const std::string & | name | ) |
Stop counting time for a specific chunk of code.
static void ompl::Profiler::End | ( | const std::string & | name | ) | [inline, static] |
Stop counting time for a specific chunk of code.
Definition at line 161 of file Profiler.h.
void ompl::Profiler::event | ( | const std::string & | name, | |
const unsigned int | times = 1 | |||
) |
Count a specific event for a number of times.
static void ompl::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 146 of file Profiler.h.
static Profiler& ompl::Profiler::Instance | ( | void | ) | [static] |
Return an instance of the class.
void ompl::Profiler::printThreadInfo | ( | std::ostream & | out, | |
const PerThread & | data | |||
) | [private] |
void ompl::Profiler::start | ( | void | ) |
Start counting time.
static void ompl::Profiler::Start | ( | void | ) | [inline, static] |
Start counting time.
Definition at line 119 of file Profiler.h.
void ompl::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 ompl::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 175 of file Profiler.h.
void ompl::Profiler::stop | ( | void | ) |
Stop counting time.
static void ompl::Profiler::Stop | ( | void | ) | [inline, static] |
Stop counting time.
Definition at line 125 of file Profiler.h.
std::map<boost::thread::id, PerThread> ompl::Profiler::data_ [private] |
Definition at line 252 of file Profiler.h.
boost::mutex ompl::Profiler::lock_ [private] |
Definition at line 251 of file Profiler.h.
bool ompl::Profiler::printOnDestroy_ [private] |
Definition at line 255 of file Profiler.h.
bool ompl::Profiler::running_ [private] |
Definition at line 254 of file Profiler.h.
TimeInfo ompl::Profiler::tinfo_ [private] |
Definition at line 253 of file Profiler.h.