From d5892f379488411fd0aa384a021d20b57857bd4d Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 13 Jan 2026 07:49:45 +0500 Subject: [PATCH] engine: change sleeptime resolution from 1 microsecond to 100 microseconds, as apparently sleeping for a microsecond isn't enough to lower CPU usage --- engine/common/host.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/engine/common/host.c b/engine/common/host.c index 4f261e25..a9d0341d 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -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 ); } }