diff options
author | aliaspider | 2014-10-31 07:47:19 +0100 |
---|---|---|
committer | aliaspider | 2014-10-31 07:47:19 +0100 |
commit | 532f3cf63ff1c12eebbc2c2c69cbf886a7e73bf7 (patch) | |
tree | 9a4e49e2860e8d2d403e14f250ae9ec4b07de50a | |
parent | 8ada6093e7456c833823bb624bb24eb760ea0b14 (diff) | |
download | snes9x2005-532f3cf63ff1c12eebbc2c2c69cbf886a7e73bf7.tar.gz snes9x2005-532f3cf63ff1c12eebbc2c2c69cbf886a7e73bf7.tar.bz2 snes9x2005-532f3cf63ff1c12eebbc2c2c69cbf886a7e73bf7.zip |
add a perf counter.
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | libretro.c | 26 |
2 files changed, 30 insertions, 3 deletions
@@ -1,4 +1,5 @@ -DEBUG = 0 +DEBUG = 0 +PERF_TEST = 1 ifeq ($(platform),) platform = unix @@ -175,6 +176,10 @@ else FLAGS += -O3 -DNDEBUG endif +ifeq ($(PERF_TEST),1) +FLAGS += -DPERF_TEST +endif + LDFLAGS += $(fpic) -lz $(SHARED) FLAGS += $(fpic) FLAGS += -Isource -I. @@ -20,10 +20,25 @@ static retro_input_poll_t poll_cb = NULL; static retro_input_state_t input_cb = NULL; static retro_audio_sample_batch_t audio_batch_cb = NULL; static retro_environment_t environ_cb = NULL; - - struct retro_perf_callback perf_cb; +#ifdef PERF_TEST +#define RETRO_PERFORMANCE_INIT(name) \ + retro_perf_tick_t current_ticks;\ + static struct retro_perf_counter name = {#name};\ + if (!name.registered) perf_cb.perf_register(&(name));\ + current_ticks = name.total + +#define RETRO_PERFORMANCE_START(name) perf_cb.perf_start(&(name)) +#define RETRO_PERFORMANCE_STOP(name) \ + perf_cb.perf_stop(&(name));\ + current_ticks = name.total - current_ticks; +#else +#define RETRO_PERFORMANCE_INIT(name) +#define RETRO_PERFORMANCE_START(name) +#define RETRO_PERFORMANCE_STOP(name) +#endif + void retro_set_environment(retro_environment_t cb) { struct retro_log_callback log; @@ -354,6 +369,10 @@ void retro_deinit(void) S9xDeinitDisplay(); S9xDeinitAPU(); Deinit(); + +#ifdef PERF_TEST + perf_cb.perf_log(); +#endif } uint32 S9xReadJoypad(int port) @@ -397,7 +416,10 @@ void retro_run(void) S9xSetPlaybackRate(32040); SoundData.echo_enable = FALSE; + RETRO_PERFORMANCE_INIT(S9xMainLoop_func); + RETRO_PERFORMANCE_START(S9xMainLoop_func); S9xMainLoop(); + RETRO_PERFORMANCE_STOP(S9xMainLoop_func); static int16_t audio_buf[534 << 1]; S9xMixSamples((uint8*)audio_buf, 534 << 1); |