summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-04-22 16:33:13 +0200
committerBad Diode <bd@badd10de.dev>2023-04-22 16:33:13 +0200
commitbaf4091795c5a87ff286e83f012ac091bcdd5848 (patch)
tree1e4d9c1fa220d0a01b213ec1a13487c0315724bb
parentea20738ca2a06df8a79b3844bff7f4eaeaf3722f (diff)
downloadgba-link-cable-tester-baf4091795c5a87ff286e83f012ac091bcdd5848.tar.gz
gba-link-cable-tester-baf4091795c5a87ff286e83f012ac091bcdd5848.zip
Get more accurate frame time measurements
There were a few overflowing fixed point numbers, this should reduce the issue slightly.
-rw-r--r--src/main.c6
-rw-r--r--src/profiling.c16
2 files changed, 13 insertions, 9 deletions
diff --git a/src/main.c b/src/main.c
index 2f5d5af..0a78367 100644
--- a/src/main.c
+++ b/src/main.c
@@ -85,6 +85,7 @@ test_moving_line(void) {
85 int inc_x = 1; 85 int inc_x = 1;
86 int inc_y = 0; 86 int inc_y = 0;
87 int should_move = 1; 87 int should_move = 1;
88 screen_fill(3);
88 while (true) { 89 while (true) {
89 poll_keys(); 90 poll_keys();
90 if (key_tap(KEY_A)) { 91 if (key_tap(KEY_A)) {
@@ -98,8 +99,10 @@ test_moving_line(void) {
98 bios_vblank_wait(); 99 bios_vblank_wait();
99 FRAME_START(); 100 FRAME_START();
100 PROF(flip_buffer(), flip_cycles); 101 PROF(flip_buffer(), flip_cycles);
102#if FLIP_TYPE == 0
101 PROF(screen_fill(3), clear_cycles); 103 PROF(screen_fill(3), clear_cycles);
102 PROF(draw_line(x, y, 239 - x, 159 - y, 2), line_cycles); 104#endif
105 PROF(draw_line(x, y, 239 - x, 159 - y, 3), line_cycles);
103 x += inc_x * should_move; 106 x += inc_x * should_move;
104 y += inc_y * should_move; 107 y += inc_y * should_move;
105 if (x == 239 && inc_x == 1) { 108 if (x == 239 && inc_x == 1) {
@@ -112,6 +115,7 @@ test_moving_line(void) {
112 inc_x = 1; 115 inc_x = 1;
113 inc_y = 0; 116 inc_y = 0;
114 } 117 }
118 PROF(draw_line(x, y, 239 - x, 159 - y, 2), line_cycles);
115 FRAME_END(); 119 FRAME_END();
116 PROF_SHOW(); 120 PROF_SHOW();
117 } 121 }
diff --git a/src/profiling.c b/src/profiling.c
index 6a4d448..90215c8 100644
--- a/src/profiling.c
+++ b/src/profiling.c
@@ -9,7 +9,7 @@
9#if PROF_ENABLE > 0 && PROF_ENABLE < 3 9#if PROF_ENABLE > 0 && PROF_ENABLE < 3
10 10
11#ifndef PROF_N_FRAMES 11#ifndef PROF_N_FRAMES
12#define PROF_N_FRAMES 5 12#define PROF_N_FRAMES 30
13#endif 13#endif
14 14
15// Profile method 1: Average per N frames. 15// Profile method 1: Average per N frames.
@@ -76,17 +76,17 @@ static bool profile_bg_show = true;
76 if (profile_bg_show) {\ 76 if (profile_bg_show) {\
77 u32 frame_time =\ 77 u32 frame_time =\
78 FP_DIV(\ 78 FP_DIV(\
79 FP_NUM(avg_frame_cycles + 1, 2) * 166,\ 79 FP_NUM(avg_frame_cycles + 1, 2),\
80 FP_NUM(280896, 2) / 100,\ 80 FP_NUM(2809, 2),\
81 2);\ 81 2) * 166;\
82 u32 fps =\ 82 u32 fps =\
83 FP_DIV(\ 83 FP_DIV(\
84 FP_NUM(280896, 2),\ 84 FP_NUM(280896 * 60, 2),\
85 FP_NUM(avg_frame_cycles + 1, 2),\ 85 FP_NUM(avg_frame_cycles + 1, 2),\
86 2) * 60;\ 86 2);\
87 draw_filled_rect(8 * 18, 0, 239, 16, 0);\ 87 draw_filled_rect(8 * 18, 0, 239, 16, 0);\
88 txt_drawf("TIME: %.6d", 8 * 18, 0, 1, frame_time >> 2);\ 88 txt_drawf("TIME: %.6lu", 8 * 18, 0, 1, frame_time >> 2);\
89 txt_drawf("MAX FPS:%.4d", 8 * 18, 8, 1, (fps >> 2) + 1);\ 89 txt_drawf("MAX FPS:%.4lu", 8 * 18, 8, 1, (fps >> 2) + 1);\
90 }\ 90 }\
91 } while (0) 91 } while (0)
92 92