* Fixed memory leak in RenderTexture.cpp (tiny, but still...)
* Added Timestamping debugging code to SGSubsystems (ported from plib branch).
This commit is contained in:
parent
af75c0ca0c
commit
25cefd9129
@ -1335,7 +1335,7 @@ void RenderTexture::_ParseModeString(const char *modeString,
|
||||
tokens.push_back(buf);
|
||||
buf = strtok(NULL, " ");
|
||||
}
|
||||
|
||||
free(mode);
|
||||
for (unsigned int i = 0; i < tokens.size(); i++)
|
||||
{
|
||||
string token = tokens[i];
|
||||
|
@ -1,5 +1,6 @@
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/timing/timestamp.hxx>
|
||||
|
||||
#include "exception.hxx"
|
||||
#include "subsystem_mgr.hxx"
|
||||
@ -70,6 +71,32 @@ SGSubsystem::is_suspended () const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SGSubsystem::printTimingInformation ()
|
||||
{
|
||||
SGTimeStamp startTime, endTime;
|
||||
long duration;
|
||||
for ( eventTimeVecIterator i = timingInfo.begin();
|
||||
i != timingInfo.end();
|
||||
i++) {
|
||||
if (i == timingInfo.begin()) {
|
||||
startTime = i->getTime();
|
||||
} else {
|
||||
endTime = i->getTime();
|
||||
duration = (endTime - startTime);
|
||||
startTime = endTime;
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "- Getting to timestamp : " << i->getName() << " takes " << duration << " usec.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SGSubsystem::stamp(string name)
|
||||
{
|
||||
SGTimeStamp now;
|
||||
now.stamp();
|
||||
timingInfo.push_back(TimingInfo(name, now));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of SGSubsystemGroup.
|
||||
@ -124,7 +151,18 @@ void
|
||||
SGSubsystemGroup::update (double delta_time_sec)
|
||||
{
|
||||
for (unsigned int i = 0; i < _members.size(); i++)
|
||||
_members[i]->update(delta_time_sec); // indirect call
|
||||
{
|
||||
SGTimeStamp start, now;
|
||||
start.stamp();
|
||||
_members[i]->update(delta_time_sec); // indirect call
|
||||
now.stamp();
|
||||
long b = ( now - start );
|
||||
if ( b > 10000 ) {
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "Subsystem Timing Alert : " << b << " " << _members[i]->name);
|
||||
//int a = 1;
|
||||
_members[i]->printTimingInformation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -240,6 +278,13 @@ SGSubsystemGroup::Member::update (double delta_time_sec)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SGSubsystemGroup::Member::printTimingInformation()
|
||||
{
|
||||
subsystem->printTimingInformation();
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of SGSubsystemMgr.
|
||||
|
@ -38,10 +38,31 @@ SG_USING_STD(string);
|
||||
SG_USING_STD(vector);
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
SG_USING_STD(map);
|
||||
SG_USING_STD(vector);
|
||||
SG_USING_STD(string);
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/timing/timestamp.hxx>
|
||||
|
||||
|
||||
class TimingInfo
|
||||
{
|
||||
private:
|
||||
string eventName;
|
||||
SGTimeStamp time;
|
||||
|
||||
public:
|
||||
TimingInfo(string name, SGTimeStamp &t) { eventName = name; time = t;};
|
||||
string getName() { return eventName; };
|
||||
SGTimeStamp getTime() { return time; };
|
||||
};
|
||||
|
||||
typedef vector<TimingInfo> eventTimeVec;
|
||||
typedef vector<TimingInfo>::iterator eventTimeVecIterator;
|
||||
|
||||
|
||||
|
||||
@ -235,11 +256,18 @@ public:
|
||||
*/
|
||||
virtual bool is_suspended () const;
|
||||
|
||||
void printTimingInformation();
|
||||
|
||||
void stamp(string name);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
bool _suspended;
|
||||
|
||||
eventTimeVec timingInfo;
|
||||
//int test;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -271,6 +299,7 @@ public:
|
||||
virtual void remove_subsystem (const string &name);
|
||||
virtual bool has_subsystem (const string &name) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
struct Member {
|
||||
@ -280,6 +309,7 @@ private:
|
||||
virtual ~Member ();
|
||||
|
||||
virtual void update (double delta_time_sec);
|
||||
void printTimingInformation();
|
||||
|
||||
string name;
|
||||
SGSubsystem * subsystem;
|
||||
|
Loading…
Reference in New Issue
Block a user