SNAP Library 6.0, Developer Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
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 400 of file tm.h.

Constructor & Destructor Documentation

TTmProfiler::TTmProfiler ( )
inline

Definition at line 406 of file tm.h.

406 { }

Member Function Documentation

int TTmProfiler::AddTimer ( const TStr TimerNm)

Definition at line 1272 of file tm.cpp.

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

1272  {
1273  MxNmLen = TInt::GetMx(MxNmLen, TimerNm.Len());
1274  return TimerH.AddKey(TimerNm);
1275 }
int Len() const
Definition: dt.h:490
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1185
int AddKey(const TKey &Key)
Definition: hash.h:373
TInt MxNmLen
Definition: tm.h:402
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:403

Here is the call graph for this function:

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

Definition at line 410 of file tm.h.

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

Definition at line 413 of file tm.h.

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

413 { return TimerH.FFirstKeyId(); }
int FFirstKeyId() const
Definition: hash.h:278
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:403

Here is the caller graph for this function:

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

Definition at line 414 of file tm.h.

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

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

Here is the caller graph for this function:

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

Definition at line 411 of file tm.h.

Referenced by PrintReport().

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

Here is the caller graph for this function:

int TTmProfiler::GetTimers ( ) const
inline

Definition at line 412 of file tm.h.

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

Definition at line 1293 of file tm.cpp.

References TimerH.

Referenced by GetTimerSumSec(), and PrintReport().

1293  {
1294  return TimerH[TimerId].GetSec();
1295 }
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:403

Here is the caller graph for this function:

double TTmProfiler::GetTimerSumSec ( ) const

Definition at line 1284 of file tm.cpp.

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

Referenced by PrintReport().

1284  {
1285  double Sum = 0.0;
1286  int TimerId = GetTimerIdFFirst();
1287  while (GetTimerIdFNext(TimerId)) {
1288  Sum += GetTimerSec(TimerId);
1289  }
1290  return Sum;
1291 }
double GetTimerSec(const int &TimerId) const
Definition: tm.cpp:1293
bool GetTimerIdFNext(int &TimerId) const
Definition: tm.h:414
int GetTimerIdFFirst() const
Definition: tm.h:413

Here is the call graph for this function:

Here is the caller graph for this function:

static PTmProfiler TTmProfiler::New ( )
inlinestatic

Definition at line 407 of file tm.h.

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

Definition at line 1297 of file tm.cpp.

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

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

Here is the call graph for this function:

void TTmProfiler::ResetAll ( )

Definition at line 1277 of file tm.cpp.

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

1277  {
1278  int TimerId = GetTimerIdFFirst();
1279  while (GetTimerIdFNext(TimerId)) {
1280  ResetTimer(TimerId);
1281  }
1282 }
bool GetTimerIdFNext(int &TimerId) const
Definition: tm.h:414
int GetTimerIdFFirst() const
Definition: tm.h:413
void ResetTimer(const TStr &TimerNm)
Definition: tm.h:423

Here is the call graph for this function:

void TTmProfiler::ResetTimer ( const TStr TimerNm)
inline

Definition at line 423 of file tm.h.

Referenced by ResetAll().

423 { TimerH.GetDat(TimerNm).Reset(false); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:403
void Reset(const bool &Start)
Definition: tm.h:389

Here is the caller graph for this function:

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

Definition at line 424 of file tm.h.

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

Definition at line 416 of file tm.h.

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

Definition at line 417 of file tm.h.

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

Definition at line 419 of file tm.h.

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

Definition at line 420 of file tm.h.

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

Friends And Related Function Documentation

friend class TPt< TTmProfiler >
friend

Definition at line 400 of file tm.h.

Member Data Documentation

TCRef TTmProfiler::CRef
private

Definition at line 400 of file tm.h.

TInt TTmProfiler::MxNmLen
private

Definition at line 402 of file tm.h.

Referenced by AddTimer(), and PrintReport().

THash<TStr, TTmStopWatch> TTmProfiler::TimerH
private

Definition at line 403 of file tm.h.

Referenced by AddTimer(), and GetTimerSec().


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