SNAP Library, User Reference  2012-10-15 15:06:59
SNAP, a general purpose network analysis and graph mining library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
tm.h File Reference

Go to the source code of this file.

Classes

class  TTmInfo
class  TJulianDate
class  TSecTm
class  TTm
class  TExeTm
class  TTmStopWatch
class  TTmTimer

Typedefs

typedef TVec< TSecTmTSecTmV
typedef TKeyDat< TSecTm, TStrTSecTmStrKd
typedef TVec< TSecTmStrKdTSecTmStrKdV
typedef TVec< TTmTTmV
typedef TPair< TTm, TStrTTmStrPr
typedef TPair< TStr, TTmTStrTmPr
typedef TVec< TTmStrPrTTmStrPrV
typedef TVec< TStrTmPrTStrTmPrV

Enumerations

enum  TTmUnit {
  tmuUndef, tmu1Sec, tmu1Min, tmu10Min,
  tmu15Min, tmu30Min, tmu1Hour, tmu2Hour,
  tmu4Hour, tmu6Hour, tmu12Hour, tmuDay,
  tmuWeek, tmuMonth, tmuYear, tmuNodes,
  tmuEdges
}

Functions

 TTmProfiler ()
static PTmProfiler New ()
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

Variables

ClassTP(TTmProfiler,
PTmProfiler) private THash
< TStr, TTmStopWatch
TimerH

Typedef Documentation

Definition at line 205 of file tm.h.

Definition at line 206 of file tm.h.

typedef TVec<TSecTm> TSecTmV

Definition at line 204 of file tm.h.

typedef TPair<TStr, TTm> TStrTmPr

Definition at line 349 of file tm.h.

Definition at line 351 of file tm.h.

typedef TPair<TTm, TStr> TTmStrPr

Definition at line 348 of file tm.h.

Definition at line 350 of file tm.h.

typedef TVec<TTm> TTmV

Definition at line 347 of file tm.h.


Enumeration Type Documentation

enum TTmUnit
Enumerator:
tmuUndef 
tmu1Sec 
tmu1Min 
tmu10Min 
tmu15Min 
tmu30Min 
tmu1Hour 
tmu2Hour 
tmu4Hour 
tmu6Hour 
tmu12Hour 
tmuDay 
tmuWeek 
tmuMonth 
tmuYear 
tmuNodes 
tmuEdges 

Definition at line 9 of file tm.h.

             {
  tmuUndef, tmu1Sec, tmu1Min, tmu10Min, tmu15Min, tmu30Min,
  tmu1Hour, tmu2Hour, tmu4Hour, tmu6Hour, tmu12Hour, tmuDay, tmuWeek, // Sunday is the start of the week
  tmuMonth, tmuYear, tmuNodes, tmuEdges
  // wrap around time
  // tmuWrapHour, tmuWrapDay, tmuWrapWeek, tmuWrapMonth, tmuWrapYear
} TTmUnit;

Function Documentation

int TTmProfiler::AddTimer ( const TStr TimerNm)

Definition at line 1286 of file tm.cpp.

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

Definition at line 410 of file tm.h.

{ return TimerH.GetKeyId(TimerNm); }
int GetTimerIdFFirst ( ) const

Definition at line 413 of file tm.h.

{ return TimerH.FFirstKeyId(); }
bool GetTimerIdFNext ( int &  TimerId) const

Definition at line 414 of file tm.h.

{ return TimerH.FNextKeyId(TimerId); }
TStr GetTimerNm ( const int &  TimerId) const

Definition at line 411 of file tm.h.

{ return TimerH.GetKey(TimerId); }
int GetTimers ( ) const

Definition at line 412 of file tm.h.

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

Definition at line 1307 of file tm.cpp.

                                                        {
    return TimerH[TimerId].GetSec();
}
double TTmProfiler::GetTimerSumSec ( ) const

Definition at line 1298 of file tm.cpp.

                                         {
        double Sum = 0.0;
    int TimerId = GetTimerIdFFirst();
        while (GetTimerIdFNext(TimerId)) {
                Sum += GetTimerSec(TimerId);
        }
    return Sum;
}
static PTmProfiler New ( ) [static]

Definition at line 407 of file tm.h.

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

Definition at line 1311 of file tm.cpp.

                                                         {
    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");
}

Definition at line 1291 of file tm.cpp.

                           {
    int TimerId = GetTimerIdFFirst();
        while (GetTimerIdFNext(TimerId)) {
                ResetTimer(TimerId);
        }
}
void ResetTimer ( const TStr TimerNm)

Definition at line 423 of file tm.h.

{ TimerH.GetDat(TimerNm).Reset(false); }
void ResetTimer ( const int &  TimerId)

Definition at line 424 of file tm.h.

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

Definition at line 416 of file tm.h.

{ TimerH.GetDat(TimerNm).Start(); }
void StartTimer ( const int &  TimerId)

Definition at line 417 of file tm.h.

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

Definition at line 419 of file tm.h.

{ TimerH.GetDat(TimerNm).Stop(); }
void StopTimer ( const int &  TimerId)

Definition at line 420 of file tm.h.

{ TimerH[TimerId].Stop(); }

Definition at line 406 of file tm.h.

{ }

Variable Documentation

ClassTP (TTmProfiler, PTmProfiler) private THash<TStr, TTmStopWatch> TimerH

Definition at line 400 of file tm.h.