Improve timing statistics
Enable/disable and print statistics at run-time. Configurable intervals and filters.
This commit is contained in:
parent
b4c47b06d5
commit
38226af24e
1 changed files with 31 additions and 0 deletions
|
@ -121,6 +121,15 @@ static void fgMainLoop( void ) {
|
|||
static SGPropertyNode_ptr frame_signal
|
||||
= fgGetNode("/sim/signals/frame", true);
|
||||
|
||||
static SGPropertyNode_ptr _statisticsFlag
|
||||
= fgGetNode("/sim/timing-statistics/enabled", true);
|
||||
static SGPropertyNode_ptr _statisticsInterval
|
||||
= fgGetNode("/sim/timing-statistics/interval-s", true);
|
||||
static SGPropertyNode_ptr _statiticsMinJitter
|
||||
= fgGetNode("/sim/timing-statistics/min-jitter-ms", true);
|
||||
static SGPropertyNode_ptr _statiticsMinTime
|
||||
= fgGetNode("/sim/timing-statistics/min-time-ms", true);
|
||||
|
||||
frame_signal->fireValueChanged();
|
||||
SGCloudLayer::enable_bump_mapping = fgGetBool("/sim/rendering/bump-mapping");
|
||||
|
||||
|
@ -206,6 +215,28 @@ static void fgMainLoop( void ) {
|
|||
simgear::sleepForMSec(500);
|
||||
}
|
||||
}
|
||||
|
||||
// print timing statistics
|
||||
static bool _lastStatisticsFlag = false;
|
||||
if (_lastStatisticsFlag != _statisticsFlag->getBoolValue())
|
||||
{
|
||||
// flag has changed, update subsystem manager
|
||||
_lastStatisticsFlag = _statisticsFlag->getBoolValue();
|
||||
globals->get_subsystem_mgr()->collectDebugTiming(_lastStatisticsFlag);
|
||||
}
|
||||
if (_lastStatisticsFlag)
|
||||
{
|
||||
static double elapsed = 0;
|
||||
elapsed += real_dt;
|
||||
if (elapsed >= _statisticsInterval->getDoubleValue())
|
||||
{
|
||||
// print and reset timing statistics
|
||||
globals->get_subsystem_mgr()->printTimingStatistics(_statiticsMinTime->getDoubleValue(),
|
||||
_statiticsMinJitter->getDoubleValue());
|
||||
elapsed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
simgear::AtomicChangeListener::fireChangeListeners();
|
||||
|
||||
SG_LOG( SG_ALL, SG_DEBUG, "" );
|
||||
|
|
Loading…
Add table
Reference in a new issue