Sirikata
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
Sirikata::TimeProfiler Class Reference

A simple class which helps to time profiling to determine what fraction of time each component of a loop is taking. More...

#include <TimeProfiler.hpp>

Collaboration diagram for Sirikata::TimeProfiler:

List of all members.

Classes

struct  Stage

Public Member Functions

 TimeProfiler (const Context *ctx, const String &name)
 ~TimeProfiler ()
StageaddStage (const String &name)
 Add a stage for profiling, not categorized under any group.
StageaddStage (const String &group_name, const String &name)
 Add a stage for profiling under the specified group.
void report () const

Private Types

typedef std::vector< Stage * > StageList
typedef std::map< String,
StageList
GroupMap

Private Member Functions

void remove (Stage *stage)

Private Attributes

const ContextmContext
String mName
GroupMap mGroups
StageList mFreeStages

Friends

class Stage

Detailed Description

A simple class which helps to time profiling to determine what fraction of time each component of a loop is taking.

It assumes each step is performed every time. Events with human-friendly names are added to the list and then the main loop simply indicates when each stage completes. When complete, call the report method to get a simple analysis.


Member Typedef Documentation

typedef std::map<String, StageList> Sirikata::TimeProfiler::GroupMap [private]
typedef std::vector<Stage*> Sirikata::TimeProfiler::StageList [private]

Constructor & Destructor Documentation

Sirikata::TimeProfiler::TimeProfiler ( const Context ctx,
const String &  name 
)
Sirikata::TimeProfiler::~TimeProfiler ( )

References mFreeStages, and mGroups.


Member Function Documentation

TimeProfiler::Stage * Sirikata::TimeProfiler::addStage ( const String &  name)
TimeProfiler::Stage * Sirikata::TimeProfiler::addStage ( const String &  group_name,
const String &  name 
)

Add a stage for profiling under the specified group.

Returns a Stage which can be used to update the statistics on each iteration. Note that the caller obtains ownership of the stage and is responsible for freeing it.

References mGroups, and Stage.

void Sirikata::TimeProfiler::remove ( Stage stage) [private]

References mFreeStages, and mGroups.

void Sirikata::TimeProfiler::report ( ) const

Friends And Related Function Documentation

friend class Stage [friend]

Referenced by addStage().


Member Data Documentation

Referenced by report().


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