Skip to content

Commit

Permalink
Optimize optimal frame calculation
Browse files Browse the repository at this point in the history
No need to iterate all frames, we can exit as soon as we hit a frametime that is higher than desired as we are iterating over the sorted array
  • Loading branch information
Aciz committed Aug 11, 2024
1 parent 095b0f2 commit f436f32
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,11 @@ static void CL_TimedemoResults(void) {
numOptimalFrames = 0;

for (i = 0; i < numFrames; i++) {
if (sortedFrametimes[i] / 1000.0f <= desiredFrametime) {
numOptimalFrames++;
if (sortedFrametimes[i] / 1000.0f > desiredFrametime) {
break;
}

numOptimalFrames++;
}

Com_Printf("\n----- Benchmark results -----\n");
Expand Down

0 comments on commit f436f32

Please sign in to comment.