SNAP Library 3.0, User Reference  2016-07-20 17:56:49
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>

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.

1272  {
1273  MxNmLen = TInt::GetMx(MxNmLen, TimerNm.Len());
1274  return TimerH.AddKey(TimerNm);
1275 }
int Len() const
Definition: dt.h:487
static int GetMx(const int &Int1, const int &Int2)
Definition: dt.h:1092
int AddKey(const TKey &Key)
Definition: hash.h:331
TInt MxNmLen
Definition: tm.h:402
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:403
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:424
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:403
int TTmProfiler::GetTimerIdFFirst ( ) const
inline

Definition at line 413 of file tm.h.

413 { return TimerH.FFirstKeyId(); }
int FFirstKeyId() const
Definition: hash.h:236
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:403
bool TTmProfiler::GetTimerIdFNext ( int &  TimerId) const
inline

Definition at line 414 of file tm.h.

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

Definition at line 411 of file tm.h.

411 { return TimerH.GetKey(TimerId); }
THash< TStr, TTmStopWatch > TimerH
Definition: tm.h:403
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210
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:186
double TTmProfiler::GetTimerSec ( const int &  TimerId) const

Definition at line 1293 of file tm.cpp.

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

Definition at line 1284 of file tm.cpp.

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
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.

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:487
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:476
void TTmProfiler::ResetAll ( )

Definition at line 1277 of file tm.cpp.

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
void TTmProfiler::ResetTimer ( const TStr TimerNm)
inline

Definition at line 423 of file tm.h.

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

THash<TStr, TTmStopWatch> TTmProfiler::TimerH
private

Definition at line 403 of file tm.h.


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