Add sleep_random function for debugging purposes

This commit is contained in:
Henrik Rydgård committed 2025-05-13 10:41:13 +02:00
1 parent e1e352c5b5
commit 80a11e8cbe
2 files changed
+12

No files matched your search

+9
View File
@@ -4,6 +4,7 @@
#include <cstdint>
#include "Common/TimeUtil.h"
#include "Common/Data/Random/Rng.h"
#include "Common/Log.h"
#ifdef HAVE_LIBNX
@@ -339,3 +340,11 @@ void GetCurrentTimeFormatted(char formattedTime[13]) {
// Now tack on the milliseconds
snprintf(formattedTime, 11, "%s:%03u", tmp, milliseconds % 1000);
}
// We don't even bother synchronizing this, it's fine if threads stomp a bit.
static GMRng g_sleepRandom;
void sleep_random(double minSeconds, double maxSeconds) {
const double waitSeconds = minSeconds + (maxSeconds - minSeconds) * g_sleepRandom.F();
sleep_precise(waitSeconds);
}