OpenClonk
C4Stat Class Reference

#include <C4Stat.h>

Collaboration diagram for C4Stat:
[legend]

Public Member Functions

 C4Stat (const char *strName)
 
 ~C4Stat ()
 
void Start ()
 
void Stop ()
 
void Reset ()
 
void ResetPart ()
 

Static Public Member Functions

static C4MainStatgetMainStat ()
 

Protected Attributes

C4StatpNext
 
C4StatpPrev
 
C4TimeMilliseconds tStartTime
 
unsigned int iStartCalled
 
uint32_t tTimeSum
 
unsigned int iCount
 
uint32_t tTimeSumPart
 
unsigned int iCountPart
 
const char * strName
 
bool bRegistred
 

Friends

class C4MainStat
 

Detailed Description

Definition at line 49 of file C4Stat.h.

Constructor & Destructor Documentation

◆ C4Stat()

C4Stat::C4Stat ( const char *  strName)

Definition at line 164 of file C4Stat.cpp.

References getMainStat(), C4MainStat::RegisterStat(), and Reset().

165  : strName(strnName)
166 {
167  Reset();
168  getMainStat()->RegisterStat(this);
169 }
void RegisterStat(C4Stat *pStat)
Definition: C4Stat.cpp:27
void Reset()
Definition: C4Stat.cpp:176
const char * strName
Definition: C4Stat.h:114
static C4MainStat * getMainStat()
Definition: C4Stat.cpp:192
Here is the call graph for this function:

◆ ~C4Stat()

C4Stat::~C4Stat ( )

Definition at line 171 of file C4Stat.cpp.

References getMainStat(), and C4MainStat::UnRegStat().

172 {
173  getMainStat()->UnRegStat(this);
174 }
void UnRegStat(C4Stat *pStat)
Definition: C4Stat.cpp:45
static C4MainStat * getMainStat()
Definition: C4Stat.cpp:192
Here is the call graph for this function:

Member Function Documentation

◆ getMainStat()

C4MainStat * C4Stat::getMainStat ( )
static

Definition at line 192 of file C4Stat.cpp.

References C4MainStat.

Referenced by C4Stat(), and ~C4Stat().

193 {
194  static C4MainStat *pMainStat = new C4MainStat();
195  return pMainStat;
196 }
friend class C4MainStat
Definition: C4Stat.h:51
Here is the caller graph for this function:

◆ Reset()

void C4Stat::Reset ( )

Definition at line 176 of file C4Stat.cpp.

References iCount, iStartCalled, ResetPart(), and tTimeSum.

Referenced by C4Stat().

177 {
178  iStartCalled = 0;
179 
180  tTimeSum = 0;
181  iCount = 0;
182 
183  ResetPart();
184 }
unsigned int iStartCalled
Definition: C4Stat.h:93
void ResetPart()
Definition: C4Stat.cpp:186
uint32_t tTimeSum
Definition: C4Stat.h:99
unsigned int iCount
Definition: C4Stat.h:102
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetPart()

void C4Stat::ResetPart ( )

Definition at line 186 of file C4Stat.cpp.

References iCountPart, and tTimeSumPart.

Referenced by Reset().

187 {
188  tTimeSumPart = 0;
189  iCountPart = 0;
190 }
uint32_t tTimeSumPart
Definition: C4Stat.h:107
unsigned int iCountPart
Definition: C4Stat.h:110
Here is the caller graph for this function:

◆ Start()

void C4Stat::Start ( )
inline

Definition at line 57 of file C4Stat.h.

References C4TimeMilliseconds::Now().

58  {
59  if (!iStartCalled)
61  iCount ++;
62  iCountPart ++;
63  iStartCalled ++;
64  }
unsigned int iStartCalled
Definition: C4Stat.h:93
C4TimeMilliseconds tStartTime
Definition: C4Stat.h:90
unsigned int iCount
Definition: C4Stat.h:102
unsigned int iCountPart
Definition: C4Stat.h:110
static C4TimeMilliseconds Now()
Here is the call graph for this function:

◆ Stop()

void C4Stat::Stop ( )
inline

Definition at line 66 of file C4Stat.h.

References C4TimeMilliseconds::Now(), C4MainStat::Reset(), and C4MainStat::ResetPart().

67  {
68  assert(iStartCalled);
69  iStartCalled --;
70  if (!iStartCalled && iCount >= 100)
71  {
72  uint32_t tTime = C4TimeMilliseconds::Now() - tStartTime;
73 
74  tTimeSum += tTime;
75  tTimeSumPart += tTime;
76  }
77  }
uint32_t tTimeSumPart
Definition: C4Stat.h:107
unsigned int iStartCalled
Definition: C4Stat.h:93
uint32_t tTimeSum
Definition: C4Stat.h:99
C4TimeMilliseconds tStartTime
Definition: C4Stat.h:90
unsigned int iCount
Definition: C4Stat.h:102
static C4TimeMilliseconds Now()
Here is the call graph for this function:

Friends And Related Function Documentation

◆ C4MainStat

friend class C4MainStat
friend

Definition at line 51 of file C4Stat.h.

Referenced by getMainStat().

Member Data Documentation

◆ bRegistred

bool C4Stat::bRegistred
protected

Definition at line 117 of file C4Stat.h.

◆ iCount

unsigned int C4Stat::iCount
protected

Definition at line 102 of file C4Stat.h.

Referenced by Reset(), and C4MainStat::Show().

◆ iCountPart

unsigned int C4Stat::iCountPart
protected

Definition at line 110 of file C4Stat.h.

Referenced by ResetPart(), and C4MainStat::ShowPart().

◆ iStartCalled

unsigned int C4Stat::iStartCalled
protected

Definition at line 93 of file C4Stat.h.

Referenced by Reset().

◆ pNext

◆ pPrev

C4Stat* C4Stat::pPrev
protected

Definition at line 88 of file C4Stat.h.

Referenced by C4MainStat::RegisterStat(), and C4MainStat::UnRegStat().

◆ strName

const char* C4Stat::strName
protected

Definition at line 114 of file C4Stat.h.

Referenced by C4MainStat::Show(), and C4MainStat::ShowPart().

◆ tStartTime

C4TimeMilliseconds C4Stat::tStartTime
protected

Definition at line 90 of file C4Stat.h.

◆ tTimeSum

uint32_t C4Stat::tTimeSum
protected

Definition at line 99 of file C4Stat.h.

Referenced by Reset(), and C4MainStat::Show().

◆ tTimeSumPart

uint32_t C4Stat::tTimeSumPart
protected

Definition at line 107 of file C4Stat.h.

Referenced by ResetPart(), and C4MainStat::ShowPart().


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