#include <simgear/debug/logstream.hxx>
+#include <simgear/timing/timestamp.hxx>
#include "exception.hxx"
#include "subsystem_mgr.hxx"
}
+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));
+}
+
\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGSubsystemGroup.
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
}
+void
+SGSubsystemGroup::Member::printTimingInformation()
+{
+ subsystem->printTimingInformation();
+}
+
+
\f
////////////////////////////////////////////////////////////////////////
// Implementation of SGSubsystemMgr.
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;
\f
*/
virtual bool is_suspended () const;
+ void printTimingInformation();
+
+ void stamp(string name);
+
protected:
bool _suspended;
+ eventTimeVec timingInfo;
+ //int test;
+
};
virtual void remove_subsystem (const string &name);
virtual bool has_subsystem (const string &name) const;
+
private:
struct Member {
virtual ~Member ();
virtual void update (double delta_time_sec);
+ void printTimingInformation();
string name;
SGSubsystem * subsystem;