| 
    SNAP Library 2.0, Developer Reference
    2013-05-13 16:33:57
    
   SNAP, a general purpose, high performance system for analysis and manipulation of large networks 
   | 
  
  
  
 
#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, TTmStopWatch > | TimerH | 
Friends | |
| class | TPt< TTmProfiler > | 
| TTmProfiler::TTmProfiler | ( | ) |  [inline] | 
        
| 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.

| int TTmProfiler::GetTimerId | ( | const TStr & | TimerNm | ) |  const [inline] | 
        
| int TTmProfiler::GetTimerIdFFirst | ( | ) |  const [inline] | 
        
Definition at line 412 of file tm.h.
Referenced by GetTimerSumSec(), PrintReport(), and ResetAll().
{ return TimerH.FFirstKeyId(); }

| bool TTmProfiler::GetTimerIdFNext | ( | int & | TimerId | ) |  const [inline] | 
        
Definition at line 413 of file tm.h.
Referenced by GetTimerSumSec(), PrintReport(), and ResetAll().
{ return TimerH.FNextKeyId(TimerId); }

| TStr TTmProfiler::GetTimerNm | ( | const int & | TimerId | ) |  const [inline] | 
        
Definition at line 410 of file tm.h.
Referenced by PrintReport().

| int TTmProfiler::GetTimers | ( | ) |  const [inline] | 
        
| double TTmProfiler::GetTimerSec | ( | const int & | TimerId | ) | const | 
Definition at line 1288 of file tm.cpp.
References TimerH.
Referenced by GetTimerSumSec(), and PrintReport().
                                                        {
    return TimerH[TimerId].GetSec();
}

| double TTmProfiler::GetTimerSumSec | ( | ) | const | 
Definition at line 1279 of file tm.cpp.
References GetTimerIdFFirst(), GetTimerIdFNext(), and GetTimerSec().
Referenced by PrintReport().
                                         {
        double Sum = 0.0;
    int TimerId = GetTimerIdFFirst();
        while (GetTimerIdFNext(TimerId)) {
                Sum += GetTimerSec(TimerId);
        }
    return Sum;
}


| static PTmProfiler TTmProfiler::New | ( | ) |  [inline, static] | 
        
Definition at line 406 of file tm.h.
{ return new TTmProfiler; }
| 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.
                                                         {
    const double TimerSumSec = GetTimerSumSec();
        printf("-- %s --\n", ProfileNm.CStr());
    printf("Sum: (%.2f sec):\n", TimerSumSec);
    int TimerId = GetTimerIdFFirst();
        while (GetTimerIdFNext(TimerId)) {
        // get timer name
        TStr TimerNm = GetTimerNm(TimerId);
        TimerNm = TStr::GetSpaceStr(TimerNm.Len() - MxNmLen) + TimerNm;
        // get timer time and precentage
        if (TimerSumSec > 0.0) {
            const double TimerSec = GetTimerSec(TimerId);
            const double TimerPerc =  TimerSec / TimerSumSec * 100.0;
            printf(" %s: %.2fs [%.2f%%]\n", TimerNm.CStr(), TimerSec, TimerPerc);
        } else {
            printf(" %s: -\n", TimerNm.CStr());
        }
    }
        printf("--\n");
}

| void TTmProfiler::ResetAll | ( | ) | 
Definition at line 1272 of file tm.cpp.
References GetTimerIdFFirst(), GetTimerIdFNext(), and ResetTimer().
                           {
    int TimerId = GetTimerIdFFirst();
        while (GetTimerIdFNext(TimerId)) {
                ResetTimer(TimerId);
        }
}

| void TTmProfiler::ResetTimer | ( | const TStr & | TimerNm | ) |  [inline] | 
        
| void TTmProfiler::ResetTimer | ( | const int & | TimerId | ) |  [inline] | 
        
| void TTmProfiler::StartTimer | ( | const TStr & | TimerNm | ) |  [inline] | 
        
| void TTmProfiler::StartTimer | ( | const int & | TimerId | ) |  [inline] | 
        
| void TTmProfiler::StopTimer | ( | const TStr & | TimerNm | ) |  [inline] | 
        
| void TTmProfiler::StopTimer | ( | const int & | TimerId | ) |  [inline] | 
        
friend class TPt< TTmProfiler > [friend] | 
        
TCRef TTmProfiler::CRef [private] | 
        
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().