This commit is contained in:
Sasha Szpakowski
2024-10-17 23:10:10 -03:00
parent 8c52dce565
commit 7ca40027e0
224 changed files with 8872 additions and 6448 deletions
+30 -2
View File
@@ -178,7 +178,7 @@ int main(int argc, char *argv[])
/* Wait for the results to be seen */
SDL_Delay(1 * 1000);
/* Check accuracy of precise delay */
/* Check accuracy of nanosecond delay */
{
Uint64 desired_delay = SDL_NS_PER_SECOND / 60;
Uint64 actual_delay;
@@ -188,7 +188,7 @@ int main(int argc, char *argv[])
SDL_DelayNS(1);
now = SDL_GetTicksNS();
actual_delay = (now - start);
SDL_Log("Minimum precise delay: %" SDL_PRIu64 " ns\n", actual_delay);
SDL_Log("Minimum nanosecond delay: %" SDL_PRIu64 " ns\n", actual_delay);
SDL_Log("Timing 100 frames at 60 FPS\n");
for (i = 0; i < 100; ++i) {
@@ -206,6 +206,34 @@ int main(int argc, char *argv[])
/* Wait for the results to be seen */
SDL_Delay(1 * 1000);
/* Check accuracy of precise delay */
{
Uint64 desired_delay = SDL_NS_PER_SECOND / 60;
Uint64 actual_delay;
Uint64 total_overslept = 0;
start = SDL_GetTicksNS();
SDL_DelayPrecise(1);
now = SDL_GetTicksNS();
actual_delay = (now - start);
SDL_Log("Minimum precise delay: %" SDL_PRIu64 " ns\n", actual_delay);
SDL_Log("Timing 100 frames at 60 FPS\n");
for (i = 0; i < 100; ++i) {
start = SDL_GetTicksNS();
SDL_DelayPrecise(desired_delay);
now = SDL_GetTicksNS();
actual_delay = (now - start);
if (actual_delay > desired_delay) {
total_overslept += (actual_delay - desired_delay);
}
}
SDL_Log("Overslept %.2f ms\n", (double)total_overslept / SDL_NS_PER_MS);
}
/* Wait for the results to be seen */
SDL_Delay(1 * 1000);
/* Test multiple timers */
SDL_Log("Testing multiple timers...\n");
t1 = SDL_AddTimer(100, callback, (void *)1);