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());
|
_warp->getIntValue());
|
||||||
globals->set_time_params(_impl);
|
globals->set_time_params(_impl);
|
||||||
|
|
||||||
// frame/update-rate counters
|
// frame-rate / worst-case delay / update-rate counters
|
||||||
_frameRate = fgGetNode("/sim/frame-rate", true);
|
_frameRate = fgGetNode("/sim/frame-rate", true);
|
||||||
|
_frameDelayMax = fgGetNode("/sim/frame-delay-max-ms", true);
|
||||||
_lastFrameTime = 0;
|
_lastFrameTime = 0;
|
||||||
|
_wcFrameDelayMax = 0.0;
|
||||||
_frameCount = 0;
|
_frameCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +162,9 @@ void TimeManager::computeTimeDeltas(double& simDt, double& realDt)
|
||||||
SGTimeStamp currentStamp;
|
SGTimeStamp currentStamp;
|
||||||
currentStamp.stamp();
|
currentStamp.stamp();
|
||||||
double dt = (currentStamp - _lastStamp).toSecs();
|
double dt = (currentStamp - _lastStamp).toSecs();
|
||||||
|
if (dt > _wcFrameDelayMax)
|
||||||
|
_wcFrameDelayMax = dt;
|
||||||
|
|
||||||
// Limit the time we need to spend in simulation loops
|
// Limit the time we need to spend in simulation loops
|
||||||
// That means, if the /sim/max-simtime-per-frame value is strictly positive
|
// That means, if the /sim/max-simtime-per-frame value is strictly positive
|
||||||
// you can limit the maximum amount of time you will do simulations for
|
// you can limit the maximum amount of time you will do simulations for
|
||||||
|
@ -251,7 +255,9 @@ void TimeManager::computeFrameRate()
|
||||||
// Calculate frame rate average
|
// Calculate frame rate average
|
||||||
if ((_impl->get_cur_time() != _lastFrameTime)) {
|
if ((_impl->get_cur_time() != _lastFrameTime)) {
|
||||||
_frameRate->setIntValue(_frameCount);
|
_frameRate->setIntValue(_frameCount);
|
||||||
|
_frameDelayMax->setDoubleValue(_wcFrameDelayMax*1000);
|
||||||
_frameCount = 0;
|
_frameCount = 0;
|
||||||
|
_wcFrameDelayMax = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastFrameTime = _impl->get_cur_time();
|
_lastFrameTime = _impl->get_cur_time();
|
||||||
|
|
|
@ -78,9 +78,11 @@ private:
|
||||||
SGPropertyNode_ptr _longitudeDeg;
|
SGPropertyNode_ptr _longitudeDeg;
|
||||||
SGPropertyNode_ptr _latitudeDeg;
|
SGPropertyNode_ptr _latitudeDeg;
|
||||||
|
|
||||||
// frame-rate / update-rate counters
|
// frame-rate / worst-case delay / update-rate counters
|
||||||
SGPropertyNode_ptr _frameRate;
|
SGPropertyNode_ptr _frameRate;
|
||||||
|
SGPropertyNode_ptr _frameDelayMax;
|
||||||
time_t _lastFrameTime;
|
time_t _lastFrameTime;
|
||||||
|
double _wcFrameDelayMax;
|
||||||
int _frameCount;
|
int _frameCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue