Skip to content

Commit f7c898f

Browse files
committed
unify(subsystem): Merge SubsystemInterface code (TheSuperHackers#2180)
1 parent ddccc0c commit f7c898f

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

Generals/Code/GameEngine/Include/Common/SubsystemInterface.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class Xfer;
3636

3737
//-------------------------------------------------------------------------------------------------
38-
/** This is the abstract base class from which all game engine subsytems should derive from.
38+
/** This is the abstract base class from which all game engine subsystems should derive from.
3939
* In order to provide consistent behaviors across all these systems, any implementation
4040
* must obey the rules defined in here
4141
*
@@ -114,6 +114,8 @@ class SubsystemInterface
114114
void DRAW(void);
115115
Real getUpdateTime(void) {return m_curUpdateTime;}
116116
Real getDrawTime(void) {return m_curDrawTime;}
117+
Bool doDumpUpdate(void) {return m_dumpUpdate;}
118+
Bool doDumpDraw(void) {return m_dumpDraw;}
117119
static Real getTotalTime(void) {return s_msConsumed;}
118120
static void clearTotalTime(void) {s_msConsumed = 0;}
119121
protected:
@@ -123,6 +125,8 @@ class SubsystemInterface
123125

124126
Real m_startDrawTimeConsumed;
125127
Real m_curDrawTime;
128+
Bool m_dumpUpdate;
129+
Bool m_dumpDraw;
126130
#else
127131
void UPDATE(void) {update();}
128132
void DRAW(void) {draw();}

Generals/Code/GameEngine/Source/Common/System/SubsystemInterface.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ SubsystemInterface::SubsystemInterface()
4343
:m_curDrawTime(0),
4444
m_startDrawTimeConsumed(0),
4545
m_startTimeConsumed(0),
46-
m_curUpdateTime(0)
46+
m_curUpdateTime(0),
47+
m_dumpUpdate(false),
48+
m_dumpDraw(false)
4749
#endif
4850
{
4951
if (TheSubsystemList) {
@@ -60,6 +62,7 @@ SubsystemInterface::~SubsystemInterface()
6062
}
6163

6264
#ifdef DUMP_PERF_STATS
65+
static const Real MIN_TIME_THRESHOLD = 0.0002f; // .2 msec. [8/13/2003]
6366
void SubsystemInterface::UPDATE(void)
6467
{
6568
__int64 startTime64;
@@ -72,8 +75,11 @@ void SubsystemInterface::UPDATE(void)
7275
m_curUpdateTime = ((double)(endTime64-startTime64))/((double)(freq64));
7376
Real subTime = s_msConsumed - m_startTimeConsumed;
7477
if (m_name.isEmpty()) return;
75-
if (m_curUpdateTime > 0.00001) {
76-
//DEBUG_LOG(("Subsys %s total time %.2f, subTime %.2f, net time %.2f",
78+
if (m_curUpdateTime>MIN_TIME_THRESHOLD) {
79+
m_dumpUpdate = true;
80+
}
81+
if (m_curUpdateTime > MIN_TIME_THRESHOLD/10.0f) {
82+
//DLOG(Debug::Format("Subsys %s total time %.2f, subTime %.2f, net time %.2f\n",
7783
// m_name.str(), m_curUpdateTime*1000, subTime*1000, (m_curUpdateTime-subTime)*1000 ));
7884

7985
m_curUpdateTime -= subTime;
@@ -95,8 +101,11 @@ void SubsystemInterface::DRAW(void)
95101
m_curDrawTime = ((double)(endTime64-startTime64))/((double)(freq64));
96102
Real subTime = s_msConsumed - m_startDrawTimeConsumed;
97103
if (m_name.isEmpty()) return;
98-
if (m_curDrawTime > 0.00001) {
99-
//DEBUG_LOG(("Subsys %s total time %.2f, subTime %.2f, net time %.2f",
104+
if (m_curDrawTime>MIN_TIME_THRESHOLD) {
105+
m_dumpDraw = true;
106+
}
107+
if (m_curDrawTime > MIN_TIME_THRESHOLD/10.0f) {
108+
//DLOG(Debug::Format("Subsys %s total time %.2f, subTime %.2f, net time %.2f\n",
100109
// m_name.str(), m_curUpdateTime*1000, subTime*1000, (m_curUpdateTime-subTime)*1000 ));
101110

102111
m_curDrawTime -= subTime;
@@ -203,15 +212,15 @@ AsciiString SubsystemInterfaceList::dumpTimesForAll()
203212
{
204213
SubsystemInterface* sys = *it;
205214
total += sys->getUpdateTime();
206-
if (sys->getUpdateTime()>0.00001f) {
215+
if (sys->doDumpUpdate()) {
207216
AsciiString curLine;
208217
curLine.format(" Time %02.2f MS update() %s \n", sys->getUpdateTime()*1000.0f, sys->getName().str());
209218
buffer.concat(curLine);
210219
} else {
211220
misc += sys->getUpdateTime();
212221
}
213222
total += sys->getDrawTime();
214-
if (sys->getDrawTime()>0.00001f) {
223+
if (sys->doDumpDraw()) {
215224
AsciiString curLine;
216225
curLine.format(" Time %02.2f MS draw () %s \n", sys->getDrawTime()*1000.0f, sys->getName().str());
217226
buffer.concat(curLine);

GeneralsMD/Code/GameEngine/Include/Common/SubsystemInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class SubsystemInterfaceList
154154
void resetAll();
155155
void shutdownAll();
156156
#ifdef DUMP_PERF_STATS
157-
AsciiString dumpTimesForAll();
157+
AsciiString dumpTimesForAll();
158158
#endif
159159

160160
private:

0 commit comments

Comments
 (0)