engine: change sleeptime resolution from 1 microsecond to 100 microseconds, as apparently sleeping for a microsecond isn't enough to lower CPU usage

This commit is contained in:
Alibek Omarov
2026-01-13 08:27:03 +05:00
parent 32aee7ef2f
commit d5892f3794
+5 -5
View File
@@ -707,18 +707,18 @@ static qboolean Host_Autosleep( double dt, double scale )
{
// Platform_Sleep isn't guaranteed to sleep an exact amount of microseconds
// so we measure the real sleep time and use it to decrease the window
double t1 = Platform_DoubleTime(), t2;
Platform_NanoSleep( sleep * 1000 ); // in usec!
t2 = Platform_DoubleTime();
realsleeptime = t2 - t1;
double t = Platform_DoubleTime();
Platform_NanoSleep( sleep * 1000 * 100 ); // sleeptime 1 ~ 100 usecs
realsleeptime = Platform_DoubleTime() - t;
timewindow -= realsleeptime;
if( host_sleeptime_debug.value )
{
counter++;
Con_NPrintf( counter, "%d: %.4f %.4f", counter, timewindow, realsleeptime );
Con_NPrintf( counter, "%d: %.6f %.6f", counter, timewindow, realsleeptime );
}
}