From d4fe4d95f105d8b9b47d26264c4876cbf4095a5d Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sat, 22 Apr 2023 18:45:35 +0200 Subject: Prepare profiling macros --- src/main.c | 44 +++++++------------------------------------- 1 file changed, 7 insertions(+), 37 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index a322df2..e694057 100644 --- a/src/main.c +++ b/src/main.c @@ -15,45 +15,13 @@ WITH REGARD TO THIS SOFTWARE. #include "renderer.c" #include "sequencer.c" +#define PROF_ENABLE 0 +#include "profiling.c" + // // Config parameters. // -#ifdef PROF_ENABLE -#if PROF_ENABLE == 0 -#define PROF(F,VAR) (profile_start(),(F),(VAR) = profile_stop()) -#elif PROF_ENABLE == 1 -#define PROF(F,VAR) (profile_start(),(F),(VAR) = MAX(profile_stop(), (VAR))) -#endif -#ifndef PROF_SHOW_X -#define PROF_SHOW_X 0 -#endif -#ifndef PROF_SHOW_Y -#define PROF_SHOW_Y 0 -#endif -#define PROF_SHOW() \ - do {\ - txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\ - txt_printf("EVAL: %lu ", eval_cycles);\ - txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+1);\ - txt_printf("FLIP: %lu ", flip_cycles);\ - txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+2);\ - txt_printf("INPUT: %lu ", input_cycles);\ - txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+3);\ - txt_printf("FRAME: %lu ", frame_counter);\ - frame_counter++;\ - } while (0) -#define PROF_INIT() \ - u32 frame_counter = 0;\ - u32 input_cycles = 0;\ - u32 eval_cycles = 0;\ - u32 flip_cycles = 0; -#else -#define PROF(F,VAR) (F) -#define PROF_SHOW() -#define PROF_INIT() -#endif - int main(void) { // Adjust system wait times. SYSTEM_WAIT = SYSTEM_WAIT_CARTRIDGE; @@ -72,12 +40,14 @@ int main(void) { sequencer_init(); // Main loop. - PROF_INIT(); while (true) { + poll_keys(); bios_vblank_wait(); - PROF(flip_buffer(), flip_cycles); + FRAME_START(); PROF(handle_sequencer_input(), input_cycles); PROF_SHOW(); + PROF(flip_buffer(), flip_cycles); + FRAME_END(); } return 0; -- cgit v1.2.1