New property reporting worst-case frame latency.
Shows maximum latency of any frame within the last second.
This commit is contained in:
parent
d7798a7cc2
commit
dca2132087
2 changed files with 11 additions and 3 deletions
|
@ -88,9 +88,11 @@ void TimeManager::init()
|
|||
_warp->getIntValue());
|
||||
globals->set_time_params(_impl);
|
||||
|
||||
// frame/update-rate counters
|
||||
// frame-rate / worst-case delay / update-rate counters
|
||||
_frameRate = fgGetNode("/sim/frame-rate", true);
|
||||
_frameDelayMax = fgGetNode("/sim/frame-delay-max-ms", true);
|
||||
_lastFrameTime = 0;
|
||||
_wcFrameDelayMax = 0.0;
|
||||
_frameCount = 0;
|
||||
}
|
||||
|
||||
|
@ -160,6 +162,8 @@ void TimeManager::computeTimeDeltas(double& simDt, double& realDt)
|
|||
SGTimeStamp currentStamp;
|
||||
currentStamp.stamp();
|
||||
double dt = (currentStamp - _lastStamp).toSecs();
|
||||
if (dt > _wcFrameDelayMax)
|
||||
_wcFrameDelayMax = dt;
|
||||
|
||||
// Limit the time we need to spend in simulation loops
|
||||
// That means, if the /sim/max-simtime-per-frame value is strictly positive
|
||||
|
@ -251,7 +255,9 @@ void TimeManager::computeFrameRate()
|
|||
// Calculate frame rate average
|
||||
if ((_impl->get_cur_time() != _lastFrameTime)) {
|
||||
_frameRate->setIntValue(_frameCount);
|
||||
_frameDelayMax->setDoubleValue(_wcFrameDelayMax*1000);
|
||||
_frameCount = 0;
|
||||
_wcFrameDelayMax = 0.0;
|
||||
}
|
||||
|
||||
_lastFrameTime = _impl->get_cur_time();
|
||||
|
|
|
@ -78,9 +78,11 @@ private:
|
|||
SGPropertyNode_ptr _longitudeDeg;
|
||||
SGPropertyNode_ptr _latitudeDeg;
|
||||
|
||||
// frame-rate / update-rate counters
|
||||
// frame-rate / worst-case delay / update-rate counters
|
||||
SGPropertyNode_ptr _frameRate;
|
||||
SGPropertyNode_ptr _frameDelayMax;
|
||||
time_t _lastFrameTime;
|
||||
double _wcFrameDelayMax;
|
||||
int _frameCount;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue