This is a simple thread-safe tool for counting time spent in various chunks of code. More...
#include <hpp/fcl/profile.h>
Classes | |
struct | AvgInfo |
Information maintained about averaged values. | |
struct | PerThread |
Information to be maintained for each thread. | |
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. More... | |
struct | TimeInfo |
Information about time spent in a section of the code. | |
Public Member Functions | |
Profiler (bool printOnDestroy=false, bool autoStart=false) | |
Constructor. | |
~Profiler (void) | |
Destructor. | |
void | start (void) |
Start counting time. | |
void | stop (void) |
Stop counting time. | |
void | clear (void) |
Clear counted time and events. | |
void | event (const std::string &name, const unsigned int times=1) |
Count a specific event for a number of times. | |
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 | end (const std::string &name) |
Stop counting time for a specific chunk of code. | |
void | status (std::ostream &out=std::cout, bool merge=true) |
Print the status of the profiled code chunks and events. | |
bool | running (void) const |
Check if the profiler is counting time or not. | |
Static Public Member Functions | |
static Profiler & | Instance (void) |
Return an instance of the class. | |
static void | Start (void) |
Start counting time. | |
static void | Stop (void) |
Stop counting time. | |
static void | Clear (void) |
Clear counted time and events. | |
static void | Event (const std::string &name, const unsigned int times=1) |
Count a specific event for a number of times. | |
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 | End (const std::string &name) |
Stop counting time for a specific chunk of code. | |
static void | Status (std::ostream &out=std::cout, bool merge=true) |
Print the status of the profiled code chunks and events. | |
static bool | Running (void) |
Check if the profiler is counting time or not. |
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.
fcl::tools::Profiler::Profiler | ( | bool | printOnDestroy = false , |
bool | autoStart = false |
||
) | [inline] |
Constructor.
It is allowed to separately instantiate this class (not only as a singleton)
References start().
fcl::tools::Profiler::~Profiler | ( | void | ) | [inline] |
Destructor.
References status().
static void fcl::tools::Profiler::Average | ( | const std::string & | name, |
const double | value | ||
) | [inline, static] |
Maintain the average of a specific value.
References average(), and Instance().
void fcl::tools::Profiler::average | ( | const std::string & | name, |
const double | value | ||
) |
Maintain the average of a specific value.
Referenced by Average().
static void fcl::tools::Profiler::Begin | ( | const std::string & | name | ) | [inline, static] |
Begin counting time for a specific chunk of code.
References begin(), and Instance().
void fcl::tools::Profiler::begin | ( | const std::string & | name | ) |
Begin counting time for a specific chunk of code.
Referenced by Begin(), and fcl::tools::Profiler::ScopedBlock::ScopedBlock().
static void fcl::tools::Profiler::Clear | ( | void | ) | [inline, static] |
Clear counted time and events.
References clear(), and Instance().
void fcl::tools::Profiler::clear | ( | void | ) |
Clear counted time and events.
Referenced by Clear().
static void fcl::tools::Profiler::End | ( | const std::string & | name | ) | [inline, static] |
Stop counting time for a specific chunk of code.
References end(), and Instance().
void fcl::tools::Profiler::end | ( | const std::string & | name | ) |
Stop counting time for a specific chunk of code.
Referenced by End(), and fcl::tools::Profiler::ScopedBlock::~ScopedBlock().
static void fcl::tools::Profiler::Event | ( | const std::string & | name, |
const unsigned int | times = 1 |
||
) | [inline, static] |
Count a specific event for a number of times.
References event(), and Instance().
void fcl::tools::Profiler::event | ( | const std::string & | name, |
const unsigned int | times = 1 |
||
) |
Count a specific event for a number of times.
Referenced by Event().
static Profiler& fcl::tools::Profiler::Instance | ( | void | ) | [static] |
bool fcl::tools::Profiler::running | ( | void | ) | const [inline] |
Check if the profiler is counting time or not.
Referenced by Running().
static bool fcl::tools::Profiler::Running | ( | void | ) | [inline, static] |
Check if the profiler is counting time or not.
References Instance(), and running().
static void fcl::tools::Profiler::Start | ( | void | ) | [inline, static] |
Start counting time.
References Instance(), and start().
void fcl::tools::Profiler::start | ( | void | ) |
Start counting time.
Referenced by Profiler(), fcl::tools::Profiler::ScopedStart::ScopedStart(), and Start().
static void fcl::tools::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.
References Instance(), and status().
void fcl::tools::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.
Referenced by Status(), and ~Profiler().
static void fcl::tools::Profiler::Stop | ( | void | ) | [inline, static] |
Stop counting time.
References Instance(), and stop().
void fcl::tools::Profiler::stop | ( | void | ) |
Stop counting time.
Referenced by Stop(), and fcl::tools::Profiler::ScopedStart::~ScopedStart().