Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
moveit::tools::Profiler Class Reference

#include <profiler.h>

Inheritance diagram for moveit::tools::Profiler:
Inheritance graph
[legend]

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. More...
 
void begin (const std::string &name)
 Begin counting time for a specific chunk of code. More...
 
void clear ()
 Clear counted time and events. More...
 
void console ()
 Print the status of the profiled code chunks and events to the console (using msg::Console) More...
 
void end (const std::string &name)
 Stop counting time for a specific chunk of code. More...
 
void event (const std::string &name, const unsigned int times=1)
 Count a specific event for a number of times. More...
 
 Profiler (bool printOnDestroy=false, bool autoStart=false)
 Constructor. It is allowed to separately instantiate this class (not only as a singleton) More...
 
bool running () const
 Check if the profiler is counting time or not. More...
 
void start ()
 Start counting time. More...
 
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. More...
 
void stop ()
 Stop counting time. More...
 
 ~Profiler ()
 Destructor. More...
 

Static Public Member Functions

static void Average (const std::string &name, const double value)
 Maintain the average of a specific value. More...
 
static void Begin (const std::string &name)
 Begin counting time for a specific chunk of code. More...
 
static void Clear ()
 Clear counted time and events. More...
 
static void Console ()
 Print the status of the profiled code chunks and events to the console (using msg::Console) More...
 
static void End (const std::string &name)
 Stop counting time for a specific chunk of code. More...
 
static void Event (const std::string &name, const unsigned int times=1)
 Count a specific event for a number of times. More...
 
static Profilerinstance ()
 Return an instance of the class. More...
 
static bool Running ()
 Check if the profiler is counting time or not. More...
 
static void Start ()
 Start counting time. More...
 
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. More...
 
static void Stop ()
 Stop counting time. More...
 

Private Member Functions

void printThreadInfo (std::ostream &out, const PerThread &data)
 

Private Attributes

std::map< boost::thread::id, PerThreaddata_
 
boost::mutex lock_
 
bool printOnDestroy_
 
bool running_
 
TimeInfo tinfo_
 

Detailed Description

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 72 of file profiler.h.

Constructor & Destructor Documentation

◆ Profiler()

moveit::tools::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 124 of file profiler.h.

◆ ~Profiler()

moveit::tools::Profiler::~Profiler ( )
inline

Destructor.

Definition at line 131 of file profiler.h.

Member Function Documentation

◆ Average()

static void moveit::tools::Profiler::Average ( const std::string &  name,
const double  value 
)
inlinestatic

Maintain the average of a specific value.

Definition at line 174 of file profiler.h.

◆ average()

void moveit::tools::Profiler::average ( const std::string &  name,
const double  value 
)

Maintain the average of a specific value.

◆ Begin()

static void moveit::tools::Profiler::Begin ( const std::string &  name)
inlinestatic

Begin counting time for a specific chunk of code.

Definition at line 183 of file profiler.h.

◆ begin()

void moveit::tools::Profiler::begin ( const std::string &  name)

Begin counting time for a specific chunk of code.

◆ Clear()

static void moveit::tools::Profiler::Clear ( )
inlinestatic

Clear counted time and events.

Definition at line 150 of file profiler.h.

◆ clear()

void moveit::tools::Profiler::clear ( )

Clear counted time and events.

◆ Console()

static void moveit::tools::Profiler::Console ( )
inlinestatic

Print the status of the profiled code chunks and events to the console (using msg::Console)

Definition at line 215 of file profiler.h.

◆ console()

void moveit::tools::Profiler::console ( )

Print the status of the profiled code chunks and events to the console (using msg::Console)

◆ End()

static void moveit::tools::Profiler::End ( const std::string &  name)
inlinestatic

Stop counting time for a specific chunk of code.

Definition at line 189 of file profiler.h.

◆ end()

void moveit::tools::Profiler::end ( const std::string &  name)

Stop counting time for a specific chunk of code.

◆ Event()

static void moveit::tools::Profiler::Event ( const std::string &  name,
const unsigned int  times = 1 
)
inlinestatic

Count a specific event for a number of times.

Definition at line 165 of file profiler.h.

◆ event()

void moveit::tools::Profiler::event ( const std::string &  name,
const unsigned int  times = 1 
)

Count a specific event for a number of times.

◆ instance()

static Profiler& moveit::tools::Profiler::instance ( )
static

Return an instance of the class.

◆ printThreadInfo()

void moveit::tools::Profiler::printThreadInfo ( std::ostream &  out,
const PerThread data 
)
private

◆ Running()

static bool moveit::tools::Profiler::Running ( )
inlinestatic

Check if the profiler is counting time or not.

Definition at line 231 of file profiler.h.

◆ running()

bool moveit::tools::Profiler::running ( ) const
inline

Check if the profiler is counting time or not.

Definition at line 225 of file profiler.h.

◆ Start()

static void moveit::tools::Profiler::Start ( )
inlinestatic

Start counting time.

Definition at line 138 of file profiler.h.

◆ start()

void moveit::tools::Profiler::start ( )

Start counting time.

◆ Status()

static void moveit::tools::Profiler::Status ( std::ostream &  out = std::cout,
bool  merge = true 
)
inlinestatic

Print the status of the profiled code chunks and events. Optionally, computation done by different threads can be printed separately.

Definition at line 203 of file profiler.h.

◆ status()

void moveit::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.

◆ Stop()

static void moveit::tools::Profiler::Stop ( )
inlinestatic

Stop counting time.

Definition at line 144 of file profiler.h.

◆ stop()

void moveit::tools::Profiler::stop ( )

Stop counting time.

Member Data Documentation

◆ data_

std::map<boost::thread::id, PerThread> moveit::tools::Profiler::data_
private

Definition at line 308 of file profiler.h.

◆ lock_

boost::mutex moveit::tools::Profiler::lock_
private

Definition at line 307 of file profiler.h.

◆ printOnDestroy_

bool moveit::tools::Profiler::printOnDestroy_
private

Definition at line 311 of file profiler.h.

◆ running_

bool moveit::tools::Profiler::running_
private

Definition at line 310 of file profiler.h.

◆ tinfo_

TimeInfo moveit::tools::Profiler::tinfo_
private

Definition at line 309 of file profiler.h.


The documentation for this class was generated from the following file:


moveit_core
Author(s): Ioan Sucan , Sachin Chitta , Acorn Pooley
autogenerated on Thu Nov 21 2024 03:23:43