All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
fcl::tools::Profiler Class Reference

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 <profile.h>

List of all members.

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 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 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 ProfilerInstance (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_

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 107 of file profile.h.


Constructor & Destructor Documentation

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)

Definition at line 162 of file profile.h.

fcl::tools::Profiler::~Profiler ( void  ) [inline]

Destructor.

Definition at line 169 of file profile.h.


Member Function Documentation

static void fcl::tools::Profiler::Average ( const std::string &  name,
const double  value 
) [inline, static]

Maintain the average of a specific value.

Definition at line 212 of file profile.h.

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

Maintain the average of a specific value.

static void fcl::tools::Profiler::Begin ( const std::string &  name) [inline, static]

Begin counting time for a specific chunk of code.

Definition at line 221 of file profile.h.

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

Begin counting time for a specific chunk of code.

static void fcl::tools::Profiler::Clear ( void  ) [inline, static]

Clear counted time and events.

Definition at line 188 of file profile.h.

void fcl::tools::Profiler::clear ( void  )

Clear counted time and events.

static void fcl::tools::Profiler::End ( const std::string &  name) [inline, static]

Stop counting time for a specific chunk of code.

Definition at line 227 of file profile.h.

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

Stop counting time for a specific chunk of code.

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.

Definition at line 203 of file profile.h.

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

Count a specific event for a number of times.

Return an instance of the class.

Author:
Ioan Sucan

Definition at line 41 of file profile.cpp.

void fcl::tools::Profiler::printThreadInfo ( std::ostream &  out,
const PerThread data 
) [private]
bool fcl::tools::Profiler::running ( void  ) const [inline]

Check if the profiler is counting time or not.

Definition at line 252 of file profile.h.

static bool fcl::tools::Profiler::Running ( void  ) [inline, static]

Check if the profiler is counting time or not.

Definition at line 258 of file profile.h.

static void fcl::tools::Profiler::Start ( void  ) [inline, static]

Start counting time.

Definition at line 176 of file profile.h.

void fcl::tools::Profiler::start ( void  )

Start counting time.

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.

Definition at line 241 of file profile.h.

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.

static void fcl::tools::Profiler::Stop ( void  ) [inline, static]

Stop counting time.

Definition at line 182 of file profile.h.

void fcl::tools::Profiler::stop ( void  )

Stop counting time.


Member Data Documentation

std::map<boost::thread::id, PerThread> fcl::tools::Profiler::data_ [private]

Definition at line 335 of file profile.h.

boost::mutex fcl::tools::Profiler::lock_ [private]

Definition at line 334 of file profile.h.

Definition at line 338 of file profile.h.

Definition at line 337 of file profile.h.

Definition at line 336 of file profile.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


fcl
Author(s): Jia Pan
autogenerated on Tue Jan 15 2013 16:05:32