Skip to content

Commit

Permalink
VSync BENCHMARKs and avoid AdvanceRandom in tests (rh-hideout#3866)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgriffin authored Dec 30, 2023
1 parent ab900e3 commit ed850d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/test/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ struct Benchmark { s32 ticks; };
static inline void BenchmarkStart(void)
{
gTestRunnerState.inBenchmark = TRUE;
// Wait for a v-blank so that comparing two benchmarks is not affected
// by the v-count (different numbers of IRQs may run).
VBlankIntrWait();
REG_TM3CNT = (TIMER_ENABLE | TIMER_64CLK) << 16;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "intro.h"
#include "main.h"
#include "trainer_hill.h"
#include "test_runner.h"
#include "constants/rgb.h"

static void VBlankIntr(void);
Expand Down Expand Up @@ -372,7 +373,7 @@ static void VBlankIntr(void)
m4aSoundMain();
TryReceiveLinkBattleData();

if (!gMain.inBattle || !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_RECORDED)))
if (!gTestRunnerEnabled && (!gMain.inBattle || !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_RECORDED))))
AdvanceRandom();

UpdateWirelessStatusIndicatorSprite();
Expand Down

0 comments on commit ed850d3

Please sign in to comment.