SNAP Library , Developer Reference  2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TTmProfiler Class Reference

#include <tm.h>

Collaboration diagram for TTmProfiler:

List of all members.

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 402 of file tm.h.


Constructor & Destructor Documentation

Definition at line 408 of file tm.h.

{ }

Member Function Documentation

int TTmProfiler::AddTimer ( const TStr TimerNm)

Definition at line 1286 of file tm.cpp.

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

                                             { 
        MxNmLen = TInt::GetMx(MxNmLen, TimerNm.Len());
        return TimerH.AddKey(TimerNm); 
}

Here is the call graph for this function:

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

Definition at line 412 of file tm.h.

{ return TimerH.GetKeyId(TimerNm); }
int TTmProfiler::GetTimerIdFFirst ( ) const [inline]

Definition at line 415 of file tm.h.

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

{ return TimerH.FFirstKeyId(); }

Here is the caller graph for this function:

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

Definition at line 416 of file tm.h.

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

{ return TimerH.FNextKeyId(TimerId); }

Here is the caller graph for this function:

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

Definition at line 413 of file tm.h.

Referenced by PrintReport().

{ return TimerH.GetKey(TimerId); }

Here is the caller graph for this function:

int TTmProfiler::GetTimers ( ) const [inline]

Definition at line 414 of file tm.h.

{ return TimerH.Len(); }
double TTmProfiler::GetTimerSec ( const int &  TimerId) const

Definition at line 1307 of file tm.cpp.

References TimerH.

Referenced by GetTimerSumSec(), and PrintReport().

                                                        {
    return TimerH[TimerId].GetSec();
}

Here is the caller graph for this function:

double TTmProfiler::GetTimerSumSec ( ) const

Definition at line 1298 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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PTmProfiler TTmProfiler::New ( ) [inline, static]

Definition at line 409 of file tm.h.

{ return new TTmProfiler; }
void TTmProfiler::PrintReport ( const TStr ProfileNm = "") const

Definition at line 1311 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");
}

Here is the call graph for this function:

Definition at line 1291 of file tm.cpp.

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

                           {
    int TimerId = GetTimerIdFFirst();
        while (GetTimerIdFNext(TimerId)) {
                ResetTimer(TimerId);
        }
}

Here is the call graph for this function:

void TTmProfiler::ResetTimer ( const TStr TimerNm) [inline]

Definition at line 425 of file tm.h.

Referenced by ResetAll().

{ TimerH.GetDat(TimerNm).Reset(false); }

Here is the caller graph for this function:

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

Definition at line 426 of file tm.h.

{ TimerH[TimerId].Reset(false); }
void TTmProfiler::StartTimer ( const TStr TimerNm) [inline]

Definition at line 418 of file tm.h.

{ TimerH.GetDat(TimerNm).Start(); }
void TTmProfiler::StartTimer ( const int &  TimerId) [inline]

Definition at line 419 of file tm.h.

{ TimerH[TimerId].Start(); }
void TTmProfiler::StopTimer ( const TStr TimerNm) [inline]

Definition at line 421 of file tm.h.

{ TimerH.GetDat(TimerNm).Stop(); }
void TTmProfiler::StopTimer ( const int &  TimerId) [inline]

Definition at line 422 of file tm.h.

{ TimerH[TimerId].Stop(); }

Friends And Related Function Documentation

friend class TPt< TTmProfiler > [friend]

Definition at line 402 of file tm.h.


Member Data Documentation

Definition at line 402 of file tm.h.

Definition at line 404 of file tm.h.

Referenced by AddTimer(), and PrintReport().

Definition at line 405 of file tm.h.

Referenced by AddTimer(), and GetTimerSec().


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