Permalink
Browse files

core: Testing performance fix

  • Loading branch information...
fzurita committed Jan 31, 2016
1 parent eb24230 commit 01f3a2edbbeca56d885c11195f5664d337891df3
Showing with 5 additions and 6 deletions.
  1. +5 −6 jni/mupen64plus-core/src/main/main.c
@@ -739,6 +739,7 @@ static void apply_speed_limiter(void)
static float VITotalDelta;
static float VIDeltas[64];
static unsigned int VIDeltasIndex;
unsigned int OverSleep = 0;
double VILimitMilliseconds = 1000.0 / ROM_PARAMS.vilimit;
double AdjustedLimit = VILimitMilliseconds * 100.0 / l_SpeedFactor; // adjust for selected emulator speed
@@ -774,15 +775,13 @@ static void apply_speed_limiter(void)
{
TimeToWait = (IntegratedDelta > ThisFrameDelta) ? -IntegratedDelta : -ThisFrameDelta;
DebugMessage(M64MSG_VERBOSE, " apply_speed_limiter(): Waiting %ims", (int) TimeToWait);
//SDL_Delay((int) TimeToWait);
int StartTime = SDL_GetTicks();
int EndTime = StartTime + TimeToWait;
while(SDL_GetTicks() <= EndTime);
unsigned int SleepStart = SDL_GetTicks();
SDL_Delay((int) TimeToWait);
// recalculate # of milliseconds that have passed since the last video interrupt,
// taking into account the time we just waited
CurrentFPSTime = SDL_GetTicks();
OverSleep = CurrentFPSTime - SleepStart - TimeToWait;
ThisFrameDelta = CurrentFPSTime - LastFPSTime - AdjustedLimit;
}
}
@@ -792,7 +791,7 @@ static void apply_speed_limiter(void)
ThisFrameDelta = 0.f;
// update our data structures

This comment has been minimized.

Show comment
Hide comment
@fzurita

fzurita Feb 1, 2016

Member

@Gillou68310 does this change make sense to you? I'm having retroben test it when he gets a chance, but I have high hopes for it.

Do you think upstream would take this? The change is basically, if we sleep for too long, then sleep less the next time around.

@fzurita

fzurita Feb 1, 2016

Member

@Gillou68310 does this change make sense to you? I'm having retroben test it when he gets a chance, but I have high hopes for it.

Do you think upstream would take this? The change is basically, if we sleep for too long, then sleep less the next time around.

LastFPSTime = CurrentFPSTime ;
LastFPSTime = CurrentFPSTime + OverSleep;
VITotalDelta += ThisFrameDelta - VIDeltas[VIDeltasIndex];
VIDeltas[VIDeltasIndex] = ThisFrameDelta;
VIDeltasIndex = (VIDeltasIndex + 1) & 63;

0 comments on commit 01f3a2e

Please sign in to comment.