Sirikata
|
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>
Classes | |
struct | Stage |
Public Member Functions | |
TimeProfiler (const Context *ctx, const String &name) | |
~TimeProfiler () | |
Stage * | addStage (const String &name) |
Add a stage for profiling, not categorized under any group. | |
Stage * | addStage (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 Context * | mContext |
String | mName |
GroupMap | mGroups |
StageList | mFreeStages |
Friends | |
class | Stage |
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.
typedef std::map<String, StageList> Sirikata::TimeProfiler::GroupMap [private] |
typedef std::vector<Stage*> Sirikata::TimeProfiler::StageList [private] |
Sirikata::TimeProfiler::TimeProfiler | ( | const Context * | ctx, |
const String & | name | ||
) |
Sirikata::TimeProfiler::~TimeProfiler | ( | ) |
References mFreeStages, and mGroups.
TimeProfiler::Stage * Sirikata::TimeProfiler::addStage | ( | const String & | name | ) |
Add a stage for profiling, not categorized under any 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 mFreeStages, and Stage.
Referenced by Sirikata::CoordinateSegmentation::CoordinateSegmentation(), Sirikata::LoadMonitor::LoadMonitor(), Sirikata::LocationService::LocationService(), Sirikata::PollingService::PollingService(), Sirikata::Graphics::ResourceLoader::ResourceLoader(), Sirikata::ServerMessageQueue::ServerMessageQueue(), Sirikata::ServerMessageReceiver::ServerMessageReceiver(), Sirikata::SessionManager::SessionManager(), and Sirikata::TimeSteppedSimulation::TimeSteppedSimulation().
TimeProfiler::Stage * Sirikata::TimeProfiler::addStage | ( | const String & | group_name, |
const String & | name | ||
) |
void Sirikata::TimeProfiler::remove | ( | Stage * | stage | ) | [private] |
References mFreeStages, and mGroups.
void Sirikata::TimeProfiler::report | ( | ) | const |
friend class Stage [friend] |
Referenced by addStage().
const Context* Sirikata::TimeProfiler::mContext [private] |
Referenced by report().
StageList Sirikata::TimeProfiler::mFreeStages [private] |
Referenced by addStage(), remove(), report(), and ~TimeProfiler().
GroupMap Sirikata::TimeProfiler::mGroups [private] |
Referenced by addStage(), remove(), report(), and ~TimeProfiler().
String Sirikata::TimeProfiler::mName [private] |
Referenced by Sirikata::TimeProfiler::Stage::name(), and report().