From fa1f5c2c84b285926fdbed54cb53ebf8a55b20c7 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sat, 16 Oct 2021 14:38:11 +0300 Subject: [PATCH] Never sleep between frames with timedemo --- src/common/frame.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/common/frame.c b/src/common/frame.c index ca4a14ed..15cf550d 100644 --- a/src/common/frame.c +++ b/src/common/frame.c @@ -142,33 +142,36 @@ Qcommon_Mainloop(void) while (1) { #ifndef DEDICATED_ONLY - // Throttle the game a little bit. - if (busywait->value) + if (!cl_timedemo->value) { - long long spintime = Sys_Microseconds(); - - while (1) + // Throttle the game a little bit. + if (busywait->value) { - /* Give the CPU a hint that this is a very tight - spinloop. One PAUSE instruction each loop is - enough to reduce power consumption and head - dispersion a lot, it's 95°C against 67°C on - a Kaby Lake laptop. */ + long long spintime = Sys_Microseconds(); + + while (1) + { + /* Give the CPU a hint that this is a very tight + spinloop. One PAUSE instruction each loop is + enough to reduce power consumption and head + dispersion a lot, it's 95°C against 67°C on + a Kaby Lake laptop. */ #if defined (__GNUC__) && (__i386 || __x86_64__) - asm("pause"); + asm("pause"); #elif defined(__aarch64__) || (defined(__ARM_ARCH) && __ARM_ARCH >= 7) || defined(__ARM_ARCH_6K__) - asm("yield"); + asm("yield"); #endif - if (Sys_Microseconds() - spintime >= 5) - { - break; + if (Sys_Microseconds() - spintime >= 5) + { + break; + } } } - } - else - { - Sys_Nanosleep(5000); + else + { + Sys_Nanosleep(5000); + } } #else Sys_Nanosleep(850000);