diff options
author | Bad Diode <bd@badd10de.dev> | 2023-04-22 18:45:35 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-04-22 18:45:35 +0200 |
commit | d4fe4d95f105d8b9b47d26264c4876cbf4095a5d (patch) | |
tree | c85cee096603ab54301537add8f7d6e231bdbd81 /src/main.c | |
parent | 320690edaff025d4d446e2f67d23304e1810196e (diff) | |
download | stepper-d4fe4d95f105d8b9b47d26264c4876cbf4095a5d.tar.gz stepper-d4fe4d95f105d8b9b47d26264c4876cbf4095a5d.zip |
Prepare profiling macros
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 44 |
1 files changed, 7 insertions, 37 deletions
@@ -15,45 +15,13 @@ WITH REGARD TO THIS SOFTWARE. | |||
15 | #include "renderer.c" | 15 | #include "renderer.c" |
16 | #include "sequencer.c" | 16 | #include "sequencer.c" |
17 | 17 | ||
18 | #define PROF_ENABLE 0 | ||
19 | #include "profiling.c" | ||
20 | |||
18 | // | 21 | // |
19 | // Config parameters. | 22 | // Config parameters. |
20 | // | 23 | // |
21 | 24 | ||
22 | #ifdef PROF_ENABLE | ||
23 | #if PROF_ENABLE == 0 | ||
24 | #define PROF(F,VAR) (profile_start(),(F),(VAR) = profile_stop()) | ||
25 | #elif PROF_ENABLE == 1 | ||
26 | #define PROF(F,VAR) (profile_start(),(F),(VAR) = MAX(profile_stop(), (VAR))) | ||
27 | #endif | ||
28 | #ifndef PROF_SHOW_X | ||
29 | #define PROF_SHOW_X 0 | ||
30 | #endif | ||
31 | #ifndef PROF_SHOW_Y | ||
32 | #define PROF_SHOW_Y 0 | ||
33 | #endif | ||
34 | #define PROF_SHOW() \ | ||
35 | do {\ | ||
36 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\ | ||
37 | txt_printf("EVAL: %lu ", eval_cycles);\ | ||
38 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+1);\ | ||
39 | txt_printf("FLIP: %lu ", flip_cycles);\ | ||
40 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+2);\ | ||
41 | txt_printf("INPUT: %lu ", input_cycles);\ | ||
42 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+3);\ | ||
43 | txt_printf("FRAME: %lu ", frame_counter);\ | ||
44 | frame_counter++;\ | ||
45 | } while (0) | ||
46 | #define PROF_INIT() \ | ||
47 | u32 frame_counter = 0;\ | ||
48 | u32 input_cycles = 0;\ | ||
49 | u32 eval_cycles = 0;\ | ||
50 | u32 flip_cycles = 0; | ||
51 | #else | ||
52 | #define PROF(F,VAR) (F) | ||
53 | #define PROF_SHOW() | ||
54 | #define PROF_INIT() | ||
55 | #endif | ||
56 | |||
57 | int main(void) { | 25 | int main(void) { |
58 | // Adjust system wait times. | 26 | // Adjust system wait times. |
59 | SYSTEM_WAIT = SYSTEM_WAIT_CARTRIDGE; | 27 | SYSTEM_WAIT = SYSTEM_WAIT_CARTRIDGE; |
@@ -72,12 +40,14 @@ int main(void) { | |||
72 | sequencer_init(); | 40 | sequencer_init(); |
73 | 41 | ||
74 | // Main loop. | 42 | // Main loop. |
75 | PROF_INIT(); | ||
76 | while (true) { | 43 | while (true) { |
44 | poll_keys(); | ||
77 | bios_vblank_wait(); | 45 | bios_vblank_wait(); |
78 | PROF(flip_buffer(), flip_cycles); | 46 | FRAME_START(); |
79 | PROF(handle_sequencer_input(), input_cycles); | 47 | PROF(handle_sequencer_input(), input_cycles); |
80 | PROF_SHOW(); | 48 | PROF_SHOW(); |
49 | PROF(flip_buffer(), flip_cycles); | ||
50 | FRAME_END(); | ||
81 | } | 51 | } |
82 | 52 | ||
83 | return 0; | 53 | return 0; |