From 74e8a59d2ff47a8720971815ceccf41569baed1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigrid=20Solveig=20Hafl=C3=ADnud=C3=B3ttir?= Date: Wed, 19 May 2021 07:29:00 +0000 Subject: [PATCH] bench mode (disabled by default) --- src/emulator.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/emulator.c b/src/emulator.c index 03541f4..e0590a8 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -26,7 +26,7 @@ static Apu apu[POLYPHONY]; static Mpu mpu; static Device *devscreen, *devmouse, *devctrl, *devmidi, *devaudio0; -Uint8 zoom = 0, debug = 0, reqdraw = 0; +Uint8 zoom = 0, debug = 0, reqdraw = 0, bench = 0; int clamp(int val, int min, int max) @@ -323,7 +323,9 @@ start(Uxn *u) while(1) { int i; SDL_Event event; - double elapsed, start = SDL_GetPerformanceCounter(); + double elapsed, start; + if(!bench) + start = SDL_GetPerformanceCounter(); while(SDL_PollEvent(&event) != 0) { switch(event.type) { case SDL_QUIT: @@ -360,8 +362,10 @@ start(Uxn *u) evaluxn(u, mempeek16(devscreen->dat, 0)); if(reqdraw) redraw(ppu.output, u); - elapsed = (SDL_GetPerformanceCounter() - start) / (double)SDL_GetPerformanceFrequency() * 1000.0f; - SDL_Delay(clamp(16.666f - elapsed, 0, 1000)); + if(!bench){ + elapsed = (SDL_GetPerformanceCounter() - start) / (double)SDL_GetPerformanceFrequency() * 1000.0f; + SDL_Delay(clamp(16.666f - elapsed, 0, 1000)); + } } return 1; }