putil: Add debug for oversleeping/undersleeping with M_limited clock

This commit is contained in:
rdb 2024-09-16 21:41:52 +02:00
parent e3f580763a
commit bb5e4454fe
2 changed files with 19 additions and 3 deletions

View File

@ -499,6 +499,8 @@ wait_until(double want_time) {
double wait_interval = (want_time - _actual_frame_time) - sleep_precision;
double now = get_real_time();
if (wait_interval > 0.0) {
Thread::sleep(wait_interval);
}
@ -507,6 +509,20 @@ wait_until(double want_time) {
(*_start_clock_busy_wait)();
#endif
_actual_frame_time = get_real_time();
if (_actual_frame_time > want_time) {
if (util_cat.is_debug()) {
util_cat.debug()
<< "Overslept by " << (int)((_actual_frame_time - want_time) * 1000000)
<< " us while waiting for next frame, consider raising sleep-precision.\n";
}
}
else if (util_cat.is_spam()) {
util_cat.spam()
<< "Busy waiting for " << (int)((want_time - _actual_frame_time) * 1000000)
<< " us.\n";
}
// Now busy-wait until the actual time elapses.
while (_actual_frame_time < want_time) {
_actual_frame_time = get_real_time();

View File

@ -129,9 +129,9 @@ get_plugin_path() {
ConfigVariableDouble sleep_precision
("sleep-precision", 0.01,
PRC_DESC("This is the accuracy within which we can expect select() to "
"return precisely. That is, if we use select() to request a "
"timeout of 1.0 seconds, we can expect to actually sleep for "
PRC_DESC("This is the accuracy within which we can expect the operating "
"system sleep call to return precisely. That is, if we request "
"a timeout of 1.0 seconds, we can expect to actually sleep for "
"somewhere between 1.0 and 1.0 + sleep-precision seconds."));
ConfigVariableBool preload_textures