SNAP Library 2.3, Developer Reference  2014-06-16 11:58:46
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TTmProfiler Class Reference

#include <tm.h>

Collaboration diagram for TTmProfiler:

Public Member Functions

 TTmProfiler ()
 
int AddTimer (const TStr &TimerNm)
 
int GetTimerId (const TStr &TimerNm) const
 
TStr GetTimerNm (const int &TimerId) const
 
int GetTimers () const
 
int GetTimerIdFFirst () const
 
bool GetTimerIdFNext (int &TimerId) const
 
void StartTimer (const TStr &TimerNm)
 
void StartTimer (const int &TimerId)
 
void StopTimer (const TStr &TimerNm)
 
void StopTimer (const int &TimerId)
 
void ResetAll ()
 
void ResetTimer (const TStr &TimerNm)
 
void ResetTimer (const int &TimerId)
 
double GetTimerSumSec () const
 
double GetTimerSec (const int &TimerId) const
 
void PrintReport (const TStr &ProfileNm="") const
 

Static Public Member Functions

static PTmProfiler New ()
 

Private Attributes

TCRef CRef
 
TInt MxNmLen
 
THash< TStr, TTmStopWatchTimerH
 

Friends

class TPt< TTmProfiler >
 

Detailed Description

Definition at line 399 of file tm.h.

Constructor & Destructor Documentation

TTmProfiler::TTmProfiler ( )
inline

Definition at line 405 of file tm.h.

405 { }

Member Function Documentation

int TTmProfiler::AddTimer ( const TStr TimerNm)

Definition at line 1267 of file tm.cpp.

References THash< TKey, TDat, THashFunc >::AddKey(), TInt::GetMx(), TStr::Len(), MxNmLen, and TimerH.

1267  {
1268  MxNmLen = TInt::GetMx(MxNmLen, TimerNm.Len());
1269  return TimerH.AddKey(TimerNm);
1270 }
int Len() const
Definition: dt.h:487
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1089
int AddKey(const TKey &Key)
Definition: hash.h:327
TInt MxNmLen
Definition: tm.h:401
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402

Here is the call graph for this function:

int TTmProfiler::GetTimerId ( const TStr TimerNm) const
inline

Definition at line 409 of file tm.h.

409 { return TimerH.GetKeyId(TimerNm); }
int GetKeyId(const TKey &Key) const
Definition: hash.h:420
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402
int TTmProfiler::GetTimerIdFFirst ( ) const
inline

Definition at line 412 of file tm.h.

Referenced by GetTimerSumSec(), PrintReport(), and ResetAll().

412 { return TimerH.FFirstKeyId(); }
int FFirstKeyId() const
Definition: hash.h:232
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402

Here is the caller graph for this function:

bool TTmProfiler::GetTimerIdFNext ( int &  TimerId) const
inline

Definition at line 413 of file tm.h.

Referenced by GetTimerSumSec(), PrintReport(), and ResetAll().

413 { return TimerH.FNextKeyId(TimerId); }
bool FNextKeyId(int &KeyId) const
Definition: hash.h:432
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402

Here is the caller graph for this function:

TStr TTmProfiler::GetTimerNm ( const int &  TimerId) const
inline

Definition at line 410 of file tm.h.

Referenced by PrintReport().

410 { return TimerH.GetKey(TimerId); }
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210

Here is the caller graph for this function:

int TTmProfiler::GetTimers ( ) const
inline

Definition at line 411 of file tm.h.

411 { return TimerH.Len(); }
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402
int Len() const
Definition: hash.h:186
double TTmProfiler::GetTimerSec ( const int &  TimerId) const

Definition at line 1288 of file tm.cpp.

References TimerH.

Referenced by GetTimerSumSec(), and PrintReport().

1288  {
1289  return TimerH[TimerId].GetSec();
1290 }
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402

Here is the caller graph for this function:

double TTmProfiler::GetTimerSumSec ( ) const

Definition at line 1279 of file tm.cpp.

References GetTimerIdFFirst(), GetTimerIdFNext(), and GetTimerSec().

Referenced by PrintReport().

1279  {
1280  double Sum = 0.0;
1281  int TimerId = GetTimerIdFFirst();
1282  while (GetTimerIdFNext(TimerId)) {
1283  Sum += GetTimerSec(TimerId);
1284  }
1285  return Sum;
1286 }
double GetTimerSec(const int &TimerId) const
Definition: tm.cpp:1288
bool GetTimerIdFNext(int &TimerId) const
Definition: tm.h:413
int GetTimerIdFFirst() const
Definition: tm.h:412

Here is the call graph for this function:

Here is the caller graph for this function:

static PTmProfiler TTmProfiler::New ( )
inlinestatic

Definition at line 406 of file tm.h.

406 { return new TTmProfiler; }
TTmProfiler()
Definition: tm.h:405
void TTmProfiler::PrintReport ( const TStr ProfileNm = "") const

Definition at line 1292 of file tm.cpp.

References TStr::CStr(), TStr::GetSpaceStr(), GetTimerIdFFirst(), GetTimerIdFNext(), GetTimerNm(), GetTimerSec(), GetTimerSumSec(), TStr::Len(), and MxNmLen.

1292  {
1293  const double TimerSumSec = GetTimerSumSec();
1294  printf("-- %s --\n", ProfileNm.CStr());
1295  printf("Sum: (%.2f sec):\n", TimerSumSec);
1296  int TimerId = GetTimerIdFFirst();
1297  while (GetTimerIdFNext(TimerId)) {
1298  // get timer name
1299  TStr TimerNm = GetTimerNm(TimerId);
1300  TimerNm = TStr::GetSpaceStr(TimerNm.Len() - MxNmLen) + TimerNm;
1301  // get timer time and precentage
1302  if (TimerSumSec > 0.0) {
1303  const double TimerSec = GetTimerSec(TimerId);
1304  const double TimerPerc = TimerSec / TimerSumSec * 100.0;
1305  printf(" %s: %.2fs [%.2f%%]\n", TimerNm.CStr(), TimerSec, TimerPerc);
1306  } else {
1307  printf(" %s: -\n", TimerNm.CStr());
1308  }
1309  }
1310  printf("--\n");
1311 }
double GetTimerSec(const int &TimerId) const
Definition: tm.cpp:1288
bool GetTimerIdFNext(int &TimerId) const
Definition: tm.h:413
static TStr GetSpaceStr(const int &Spaces)
Definition: dt.cpp:1608
int Len() const
Definition: dt.h:487
double GetTimerSumSec() const
Definition: tm.cpp:1279
int GetTimerIdFFirst() const
Definition: tm.h:412
TInt MxNmLen
Definition: tm.h:401
TStr GetTimerNm(const int &TimerId) const
Definition: tm.h:410
Definition: dt.h:412
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

void TTmProfiler::ResetAll ( )

Definition at line 1272 of file tm.cpp.

References GetTimerIdFFirst(), GetTimerIdFNext(), and ResetTimer().

1272  {
1273  int TimerId = GetTimerIdFFirst();
1274  while (GetTimerIdFNext(TimerId)) {
1275  ResetTimer(TimerId);
1276  }
1277 }
bool GetTimerIdFNext(int &TimerId) const
Definition: tm.h:413
int GetTimerIdFFirst() const
Definition: tm.h:412
void ResetTimer(const TStr &TimerNm)
Definition: tm.h:422

Here is the call graph for this function:

void TTmProfiler::ResetTimer ( const TStr TimerNm)
inline

Definition at line 422 of file tm.h.

Referenced by ResetAll().

422 { TimerH.GetDat(TimerNm).Reset(false); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402
void Reset(const bool &Start)
Definition: tm.h:388

Here is the caller graph for this function:

void TTmProfiler::ResetTimer ( const int &  TimerId)
inline

Definition at line 423 of file tm.h.

423 { TimerH[TimerId].Reset(false); }
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402
void TTmProfiler::StartTimer ( const TStr TimerNm)
inline

Definition at line 415 of file tm.h.

415 { TimerH.GetDat(TimerNm).Start(); }
void Start()
Definition: tm.h:386
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402
void TTmProfiler::StartTimer ( const int &  TimerId)
inline

Definition at line 416 of file tm.h.

416 { TimerH[TimerId].Start(); }
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402
void TTmProfiler::StopTimer ( const TStr TimerNm)
inline

Definition at line 418 of file tm.h.

418 { TimerH.GetDat(TimerNm).Stop(); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
void Stop()
Definition: tm.h:387
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402
void TTmProfiler::StopTimer ( const int &  TimerId)
inline

Definition at line 419 of file tm.h.

419 { TimerH[TimerId].Stop(); }
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:402

Friends And Related Function Documentation

friend class TPt< TTmProfiler >
friend

Definition at line 399 of file tm.h.

Member Data Documentation

TCRef TTmProfiler::CRef
private

Definition at line 399 of file tm.h.

TInt TTmProfiler::MxNmLen
private

Definition at line 401 of file tm.h.

Referenced by AddTimer(), and PrintReport().

THash<TStr, TTmStopWatch> TTmProfiler::TimerH
private

Definition at line 402 of file tm.h.

Referenced by AddTimer(), and GetTimerSec().


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