LAMA
|
Class to collect timing information about different regions in an instrumented program. More...
#include <RegionTable.hpp>
Data Structures | |
struct | CallEntry |
Structure for entry on the call stack (id, starttime) More... | |
struct | CmpString |
struct | RegionEntry |
Structure for inclusive and exclusive time of each timer. More... | |
Public Member Functions | |
RegionTable (lama::Thread::Id threadId) | |
Constructor of a new region table. | |
~RegionTable () | |
Destructor. | |
lama::Thread::Id | getId () const |
Query of the thread id to which thread table belongs. | |
int | getRegion (const char *id, const char *file, int lno) |
Get the id of a region, createas a new entry if region is not available yet. | |
void | init () |
Initialization of the timers. | |
void | start (int regionId, double wallTime) |
Enter a region with the timestamp. | |
void | stop (int regionId, double wallTime) |
Leave the region with the timestamp. | |
void | stop (const char *regionName, double wallTime) |
Leave the region with the timestamp. | |
double | elapsed (int regionId) |
Return the elapsed time up to now. | |
double | spent (int regionId) |
Return the accumulated time of a region. | |
double | spentExclusive (int regionId) |
Return the exclusive time. | |
double | spentLast (int regionId) |
Return the time of last execution. | |
const char * | getName (int regionId) |
Get name of the region. | |
void | printTimer () |
This routine prints timing information. | |
void | printTimer (FILE *f) |
Private Member Functions | |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
Private Attributes | |
std::vector< CallEntry > | callStack |
std::vector< RegionEntry > | array |
Entries for all timers. | |
lama::Thread::Id | mThreadId |
std::map< const char *, int, CmpString > | mapTimer |
Map of region strings to region ids that are the indexes to array. |
Class to collect timing information about different regions in an instrumented program.
For each region timers are defined. Timing for a routine must be started and stopped according a subroutine call structure.
start(region1) start(region2) stop(region2) start(region3) elapsed(region1) stop(region3) stop(region1)
At the end of a run, inclusive and exclusive time is available for all regions.
tracing::RegionTable::RegionTable | ( | lama::Thread::Id | threadId | ) |
Constructor of a new region table.
[in] | threadId | id of the thread to which region table belongs |
Destructor.
References printTimer().
double tracing::RegionTable::elapsed | ( | int | regionId | ) |
Return the elapsed time up to now.
It will add also the time of a running region.
References array, callStack, tracing::RegionTable::CallEntry::mRegion, tracing::RegionTable::CallEntry::mTimeStart, and tracing::walltime().
lama::Thread::Id tracing::RegionTable::getId | ( | ) | const [inline] |
Query of the thread id to which thread table belongs.
Referenced by tracing::TraceRegionRecord::enter(), tracing::TraceRegionRecord::start(), tracing::TraceRegionRecord::stop(), and tracing::TraceRegionRecord::~TraceRegionRecord().
const char * tracing::RegionTable::getName | ( | int | regionId | ) |
Get name of the region.
References array.
Referenced by tracing::TraceRegionRecord::enter(), tracing::TraceRegionRecord::spentLast(), tracing::TraceRegionRecord::start(), stop(), and tracing::TraceRegionRecord::~TraceRegionRecord().
int tracing::RegionTable::getRegion | ( | const char * | id, |
const char * | file, | ||
int | lno | ||
) |
Get the id of a region, createas a new entry if region is not available yet.
[in] | id | is the name of the region |
[in] | file | is the name of the source file where region is defined |
[in] | lno | is the line number of the region in the source file |
References array, mapTimer, tracing::RegionTable::RegionEntry::mFile, tracing::RegionTable::RegionEntry::mLine, tracing::RegionTable::RegionEntry::mName, and mThreadId.
Referenced by tracing::TraceRegionRecord::enter(), tracing::TraceRegionRecord::spentLast(), and tracing::TraceRegionRecord::start().
void tracing::RegionTable::init | ( | ) |
tracing::RegionTable::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [private] |
void tracing::RegionTable::printTimer | ( | ) |
This routine prints timing information.
References tracing::printMutex.
Referenced by ~RegionTable(), and tracing::TraceConfig::~TraceConfig().
void tracing::RegionTable::printTimer | ( | FILE * | f | ) |
double tracing::RegionTable::spent | ( | int | regionId | ) |
Return the accumulated time of a region.
References array.
double tracing::RegionTable::spentExclusive | ( | int | regionId | ) |
Return the exclusive time.
References array.
double tracing::RegionTable::spentLast | ( | int | regionId | ) |
Return the time of last execution.
References array.
Referenced by tracing::TraceRegionRecord::spentLast().
void tracing::RegionTable::start | ( | int | regionId, |
double | wallTime | ||
) |
Enter a region with the timestamp.
References callStack.
Referenced by tracing::TraceRegionRecord::enter(), and tracing::TraceRegionRecord::start().
void tracing::RegionTable::stop | ( | int | regionId, |
double | wallTime | ||
) |
Leave the region with the timestamp.
[in] | regionId | is the id of region to leave, must match the last on call stack |
[in] | wallTime | is time stamp of call |
References array, callStack, tracing::RegionTable::CallEntry::mRegion, and tracing::RegionTable::CallEntry::mTimeStart.
Referenced by tracing::TraceRegionRecord::stop(), stop(), and tracing::TraceRegionRecord::~TraceRegionRecord().
void tracing::RegionTable::stop | ( | const char * | regionName, |
double | wallTime | ||
) |
Leave the region with the timestamp.
References array, callStack, getName(), tracing::RegionTable::CallEntry::mRegion, and stop().
std::vector<RegionEntry> tracing::RegionTable::array [private] |
Entries for all timers.
Referenced by elapsed(), getName(), getRegion(), printTimer(), spent(), spentExclusive(), spentLast(), and stop().
std::vector<CallEntry> tracing::RegionTable::callStack [private] |
std::map<const char*, int, CmpString> tracing::RegionTable::mapTimer [private] |
Map of region strings to region ids that are the indexes to array.
Timer strings are given by pointer; pointers will be always valid as string remains as member variable in array.
Referenced by getRegion(), and printTimer().
Referenced by getRegion(), and printTimer().