OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4MainStat Class Reference

#include <C4Stat.h>

Collaboration diagram for C4MainStat:
[legend]

Public Member Functions

 C4MainStat ()
 
 ~C4MainStat ()
 
void Show ()
 
void ShowPart (int FrameCounter)
 
void Reset ()
 
void ResetPart ()
 

Protected Member Functions

void RegisterStat (C4Stat *pStat)
 
void UnRegStat (C4Stat *pStat)
 

Protected Attributes

C4StatpFirst
 

Friends

class C4Stat
 

Detailed Description

Definition at line 24 of file C4Stat.h.

Constructor & Destructor Documentation

C4MainStat::C4MainStat ( )

Definition at line 23 of file C4Stat.cpp.

24  : pFirst(0)
25 {
26 }
C4Stat * pFirst
Definition: C4Stat.h:39
C4MainStat::~C4MainStat ( )

Definition at line 28 of file C4Stat.cpp.

29 {
30 }

Member Function Documentation

void C4MainStat::RegisterStat ( C4Stat pStat)
protected

Definition at line 32 of file C4Stat.cpp.

References pFirst, C4Stat::pNext, and C4Stat::pPrev.

Referenced by C4Stat::C4Stat().

33 {
34  // add to list
35  if (!pFirst)
36  {
37  pFirst = pStat;
38  pStat->pNext = 0;
39  pStat->pPrev = 0;
40  }
41  else
42  {
43  pStat->pNext = pFirst;
44  pFirst->pPrev = pStat;
45  pStat->pPrev = 0;
46  pFirst = pStat;
47  }
48 }
C4Stat * pPrev
Definition: C4Stat.h:88
C4Stat * pNext
Definition: C4Stat.h:87
C4Stat * pFirst
Definition: C4Stat.h:39

Here is the caller graph for this function:

void C4MainStat::Reset ( )

Definition at line 73 of file C4Stat.cpp.

References pFirst, and C4Stat::pNext.

74 {
75  for (C4Stat* pAkt = pFirst; pAkt; pAkt = pAkt->pNext)
76  pAkt->Reset();
77 }
C4Stat * pNext
Definition: C4Stat.h:87
Definition: C4Stat.h:49
C4Stat * pFirst
Definition: C4Stat.h:39
void C4MainStat::ResetPart ( )

Definition at line 79 of file C4Stat.cpp.

References pFirst, and C4Stat::pNext.

80 {
81  for (C4Stat* pAkt = pFirst; pAkt; pAkt = pAkt->pNext)
82  pAkt->ResetPart();
83 }
C4Stat * pNext
Definition: C4Stat.h:87
Definition: C4Stat.h:49
C4Stat * pFirst
Definition: C4Stat.h:39
void C4MainStat::Show ( )

Definition at line 86 of file C4Stat.cpp.

References iCnt, C4Stat::iCount, LogSilent(), LogSilentF(), pFirst, C4Stat::pNext, stricmp(), C4Stat::strName, and C4Stat::tTimeSum.

87 {
88 
89  // count stats
90  unsigned int iCnt = 0;
91  C4Stat* pAkt;
92  for (pAkt = pFirst; pAkt; pAkt = pAkt->pNext)
93  iCnt++;
94 
95  // create array
96  C4Stat** StatArray = new C4Stat*[iCnt];
97  bool* bHS = new bool[iCnt];
98 
99  // sort it
100  unsigned int i,ii;
101  for (ii=0; ii<iCnt; ii++) bHS[ii] = false;
102  for (i=0; i<iCnt; i++)
103  {
104  C4Stat* pBestStat = nullptr;
105  unsigned int iBestNr = ~0;
106 
107  for (ii=0, pAkt = pFirst; ii<iCnt; ii++, pAkt = pAkt->pNext)
108  if (!bHS[ii])
109  {
110  if (iBestNr == ~0u)
111  {
112  iBestNr = ii;
113  pBestStat = pAkt;
114  }
115  else if (stricmp(pBestStat->strName, pAkt->strName) > 0)
116  {
117  iBestNr = ii;
118  pBestStat = pAkt;
119  }
120  }
121 
122  if (iBestNr == (unsigned int) -1)
123  break;
124  bHS[iBestNr] = true;
125 
126  StatArray[i] = pBestStat;
127  }
128 
129  delete [] bHS;
130 
131  LogSilent("** Stat");
132 
133  // output in order
134  for (i=0; i<iCnt; i++)
135  {
136  pAkt = StatArray[i];
137 
138  // output it!
139  if (pAkt->iCount)
140  LogSilentF("%s: n = %u, t = %u, td = %.2f",
141  pAkt->strName, pAkt->iCount, pAkt->tTimeSum,
142  double(pAkt->tTimeSum) / pAkt->iCount * 1000);
143  }
144 
145  // delete...
146  delete[] StatArray;
147 
148  // ok. job done
149  LogSilent("** Stat end");
150 }
bool LogSilent(const char *szMessage, bool fConsole)
Definition: C4Log.cpp:117
C4Stat * pNext
Definition: C4Stat.h:87
int stricmp(const char *s1, const char *s2)
Definition: C4Stat.h:49
bool LogSilentF(const char *strMessage,...)
Definition: C4Log.cpp:263
C4Stat * pFirst
Definition: C4Stat.h:39
int iCnt
Definition: TstC4NetIO.cpp:35
const char * strName
Definition: C4Stat.h:114

Here is the call graph for this function:

void C4MainStat::ShowPart ( int  FrameCounter)

Definition at line 152 of file C4Stat.cpp.

References C4Stat::iCountPart, LogSilentF(), pFirst, C4Stat::pNext, C4Stat::strName, and C4Stat::tTimeSumPart.

153 {
154  C4Stat* pAkt;
155 
156  // insert tick nr
157  LogSilentF("** PartStat begin %d", FrameCounter);
158 
159  // insert all stats
160  for (pAkt = pFirst; pAkt; pAkt = pAkt->pNext)
161  LogSilentF("%s: n=%u, t=%u", pAkt->strName, pAkt->iCountPart, pAkt->tTimeSumPart);
162 
163  // insert part stat end idtf
164  LogSilentF("** PartStat end\n");
165 }
C4Stat * pNext
Definition: C4Stat.h:87
uint32_t tTimeSumPart
Definition: C4Stat.h:107
Definition: C4Stat.h:49
bool LogSilentF(const char *strMessage,...)
Definition: C4Log.cpp:263
C4Stat * pFirst
Definition: C4Stat.h:39
const char * strName
Definition: C4Stat.h:114
unsigned int iCountPart
Definition: C4Stat.h:110

Here is the call graph for this function:

void C4MainStat::UnRegStat ( C4Stat pStat)
protected

Definition at line 50 of file C4Stat.cpp.

References pFirst, C4Stat::pNext, and C4Stat::pPrev.

Referenced by C4Stat::~C4Stat().

51 {
52  // first item?
53  if (!pStat->pPrev)
54  {
55  pFirst = pStat->pNext;
56  pStat->pNext = 0;
57  }
58  // last item?
59  else if (!pStat->pNext)
60  {
61  pStat->pPrev->pNext = 0;
62  pStat->pPrev = 0;
63  }
64  else
65  {
66  pStat->pNext->pPrev = pStat->pPrev;
67  pStat->pPrev->pNext = pStat->pNext;
68  pStat->pNext = 0;
69  pStat->pPrev = 0;
70  }
71 }
C4Stat * pPrev
Definition: C4Stat.h:88
C4Stat * pNext
Definition: C4Stat.h:87
C4Stat * pFirst
Definition: C4Stat.h:39

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4Stat
friend

Definition at line 26 of file C4Stat.h.

Member Data Documentation

C4Stat* C4MainStat::pFirst
protected

Definition at line 39 of file C4Stat.h.

Referenced by RegisterStat(), Reset(), ResetPart(), Show(), ShowPart(), and UnRegStat().


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