diff --git a/Makefile.common b/Makefile.common index ab4df5e620..9a55a67774 100644 --- a/Makefile.common +++ b/Makefile.common @@ -205,6 +205,7 @@ OBJ += frontend/frontend.o \ record/record_driver.o \ record/drivers/record_null.o \ performance.o \ + performance_counters.o \ verbosity.o ifneq ($(HAVE_GETOPT_LONG), 1) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 22e3e117f8..b9cd3fed4c 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -30,7 +30,7 @@ #include "../configuration.h" #include "../retroarch.h" #include "../runloop.h" -#include "../performance.h" +#include "../performance_counters.h" #include "../verbosity.h" #include "../list_special.h" diff --git a/audio/audio_dsp_filter.c b/audio/audio_dsp_filter.c index 6c68911dad..09a7759ae5 100644 --- a/audio/audio_dsp_filter.c +++ b/audio/audio_dsp_filter.c @@ -30,6 +30,7 @@ #include "../config_file_userdata.h" #include "../frontend/frontend_driver.h" #include "../performance.h" +#include "../performance_counters.h" #include "../dynamic.h" struct rarch_dsp_plug diff --git a/audio/audio_resampler_driver.c b/audio/audio_resampler_driver.c index 44855d962d..b4b770db5c 100644 --- a/audio/audio_resampler_driver.c +++ b/audio/audio_resampler_driver.c @@ -22,6 +22,7 @@ #include "../config_file_userdata.h" #ifdef RARCH_INTERNAL #include "../performance.h" +#include "../performance_counters.h" #endif #ifndef DONT_HAVE_STRING_LIST #include "../list_special.h" diff --git a/audio/audio_thread_wrapper.c b/audio/audio_thread_wrapper.c index 46a85f4c36..55bb2886f9 100644 --- a/audio/audio_thread_wrapper.c +++ b/audio/audio_thread_wrapper.c @@ -21,7 +21,7 @@ #include #include "audio_thread_wrapper.h" -#include "../performance.h" +#include "../performance_counters.h" #include "../verbosity.h" typedef struct audio_thread diff --git a/audio/audio_utils.c b/audio/audio_utils.c index b67a734e48..0946d57651 100644 --- a/audio/audio_utils.c +++ b/audio/audio_utils.c @@ -25,6 +25,7 @@ #ifdef RARCH_INTERNAL #include "../performance.h" +#include "../performance_counters.h" #endif /** diff --git a/audio/drivers/ctr_csnd_audio.c b/audio/drivers/ctr_csnd_audio.c index 32741dd2ed..3245876afa 100644 --- a/audio/drivers/ctr_csnd_audio.c +++ b/audio/drivers/ctr_csnd_audio.c @@ -18,7 +18,7 @@ #include "../audio_driver.h" #include "../../configuration.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../runloop.h" typedef struct diff --git a/audio/drivers/ctr_dsp_audio.c b/audio/drivers/ctr_dsp_audio.c index ff1ccc75b5..36ffbfc777 100644 --- a/audio/drivers/ctr_dsp_audio.c +++ b/audio/drivers/ctr_dsp_audio.c @@ -18,7 +18,7 @@ #include "../audio_driver.h" #include "../../configuration.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../runloop.h" #include "../../ctr/ctr_debug.h" diff --git a/camera/drivers/video4linux2.c b/camera/drivers/video4linux2.c index 684504ca4c..c5eba58f9b 100644 --- a/camera/drivers/video4linux2.c +++ b/camera/drivers/video4linux2.c @@ -41,7 +41,7 @@ #include #include "../camera_driver.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../verbosity.h" struct buffer diff --git a/cheevos.c b/cheevos.c index d3225bfbed..9eba3219d2 100644 --- a/cheevos.c +++ b/cheevos.c @@ -26,7 +26,7 @@ #include "libretro.h" #include "network/net_http_special.h" #include "configuration.h" -#include "performance.h" +#include "performance_counters.h" #include "msg_hash.h" #include "runloop.h" #include "core.h" diff --git a/command.c b/command.c index 36eae2360a..4259459032 100644 --- a/command.c +++ b/command.c @@ -44,7 +44,7 @@ #include "autosave.h" #include "core_info.h" #include "core_type.h" -#include "performance.h" +#include "performance_counters.h" #include "dynamic.h" #include "content.h" #include "movie.h" diff --git a/dynamic.c b/dynamic.c index cf8afb23b4..ddd52747e9 100644 --- a/dynamic.c +++ b/dynamic.c @@ -37,6 +37,7 @@ #include "location/location_driver.h" #include "record/record_driver.h" #include "core.h" +#include "performance_counters.h" #include "performance.h" #include "system.h" #include "gfx/video_context_driver.h" diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index 02961f8e83..6afaa53178 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -39,7 +39,6 @@ #include #include "../../driver.h" -#include "../../performance.h" #include "../../libretro.h" #include "../../general.h" #include "../../retroarch.h" diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index e713505ca8..0083a39401 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -47,7 +47,7 @@ #endif #include "../../core.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../defines/d3d_defines.h" #include "../../verbosity.h" diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index ccfdfafc1e..5d9999234c 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -30,7 +30,7 @@ #include "render_chain_driver.h" #include "../video_driver.h" #include "../../general.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../verbosity.h" #include "d3d.h" diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index e254216539..ead9fcbd99 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -28,7 +28,7 @@ #include "../../driver.h" #include "../../retroarch.h" -#include "../../performance.h" +#include "../../performance_counters.h" #define CTR_TOP_FRAMEBUFFER_WIDTH 400 #define CTR_TOP_FRAMEBUFFER_HEIGHT 240 diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 414a2fcdf8..f3d240fa52 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -34,7 +34,7 @@ #include "../../driver.h" #include "../../record/record_driver.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../libretro.h" #include "../../general.h" diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 5b8dfa7dee..9c8401b8fb 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -25,7 +25,7 @@ #include "../../driver.h" #include "../../general.h" #include "../../retroarch.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../verbosity.h" #include "../video_context_driver.h" #include "../font_driver.h" diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 50ae2b98ce..bbc58dc24f 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -25,7 +25,7 @@ #include "../../driver.h" #include "../../general.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../video_frame.h" #include "../video_context_driver.h" diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 59bc5831c1..73527ff83c 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -30,7 +30,7 @@ #include "../../general.h" #include "../../retroarch.h" #include "../../driver.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../font_driver.h" #include "../../content.h" #include "../../runloop.h" diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 211828a348..1147badfa2 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -36,7 +36,7 @@ #include "../../driver.h" #include "../../record/record_driver.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../libretro.h" #include "../../general.h" diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 5901e8304f..6f1bcd39dd 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -34,6 +34,7 @@ #include "../retroarch.h" #include "../runloop.h" #include "../performance.h" +#include "../performance_counters.h" #include "../list_special.h" #include "../core.h" #include "../system.h" diff --git a/gfx/video_filter.c b/gfx/video_filter.c index aa263d7a48..0f72d35560 100644 --- a/gfx/video_filter.c +++ b/gfx/video_filter.c @@ -25,6 +25,7 @@ #include "../dynamic.h" #include "../general.h" #include "../performance.h" +#include "../performance_counters.h" #include "../verbosity.h" #include "video_filter.h" #include "video_filters/softfilter.h" diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 9cfa2ca0bd..aa03dccb43 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -24,6 +24,7 @@ #include "font_driver.h" #include "video_shader_driver.h" #include "../performance.h" +#include "../performance_counters.h" #include "../runloop.h" #include "../verbosity.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 4bd73571bf..e483a0c10c 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -63,6 +63,7 @@ ENCODINGS PERFORMANCE ============================================================ */ #include "../performance.c" +#include "../performance_counters.c" /*============================================================ COMPATIBILITY diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index d27b7b3206..6b9125923f 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -30,7 +30,7 @@ #include "../input_config.h" #include "../input_joypad_driver.h" #include "../drivers_keyboard/keyboard_event_android.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../general.h" #include "../../driver.h" diff --git a/managers/state_manager.c b/managers/state_manager.c index e47e8ca500..ffe31d4f19 100644 --- a/managers/state_manager.c +++ b/managers/state_manager.c @@ -31,7 +31,7 @@ #include "../movie.h" #include "../core.h" #include "../runloop.h" -#include "../performance.h" +#include "../performance_counters.h" #include "../verbosity.h" #include "../audio/audio_driver.h" diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 6c49bcfeec..6ab52e6106 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -30,7 +30,7 @@ #include "../../managers/core_option_manager.h" #include "../../managers/cheat_manager.h" #include "../../general.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../system.h" #include "../../intl/intl.h" diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index ed07712099..ef0b7b4a31 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -30,7 +30,7 @@ #include "../../general.h" #include "../../retroarch.h" #include "../../system.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../gfx/video_shader_driver.h" diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 293fba9f12..fa0e875a99 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -29,6 +29,7 @@ #include "../../configuration.h" #include "../../performance.h" +#include "../../performance_counters.h" #include "../../input/input_autodetect.h" #include "../../input/input_config.h" #include "../../cheevos.h" diff --git a/menu/menu_animation.c b/menu/menu_animation.c index b72d7e9c37..be5365859d 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -23,6 +23,7 @@ #include "menu_animation.h" #include "../configuration.h" #include "../performance.h" +#include "../performance_counters.h" #define IDEAL_DELTA_TIME (1.0 / 60.0 * 1000000.0) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index babe720ea0..eb902a4c99 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -44,7 +44,7 @@ #include "../git_version.h" #include "../input/input_config.h" #include "../list_special.h" -#include "../performance.h" +#include "../performance_counters.h" #include "../core_info.h" #ifdef HAVE_CHEEVOS diff --git a/menu/menu_input.c b/menu/menu_input.c index a8d76940be..cfc431e7ca 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -40,6 +40,7 @@ #include "../general.h" #include "../managers/cheat_manager.h" #include "../performance.h" +#include "../performance_counters.h" #include "../core.h" #include "../input/input_joypad_driver.h" #include "../input/input_remapping.h" diff --git a/menu/menu_setting.c b/menu/menu_setting.c index ea9d339edc..d6e20db97a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -59,7 +59,7 @@ #include "../input/input_config.h" #include "../input/input_autodetect.h" #include "../config.def.h" -#include "../performance.h" +#include "../performance_counters.h" #include "../lakka.h" #include "../tasks/tasks_internal.h" diff --git a/network/net_http_special.c b/network/net_http_special.c index 3eec1fb230..62fb7c2dc7 100644 --- a/network/net_http_special.c +++ b/network/net_http_special.c @@ -19,6 +19,7 @@ #include #include "../performance.h" +#include "../performance_counters.h" #include "net_http_special.h" int net_http_get(const char **result, size_t *size, const char *url, retro_time_t *timeout) diff --git a/performance.c b/performance.c index a48377b026..5cfe6327f0 100644 --- a/performance.c +++ b/performance.c @@ -109,90 +109,6 @@ static int clock_gettime(int clk_ik, struct timespec *t) #include "frontend/drivers/platform_linux.h" #endif -static struct retro_perf_counter *perf_counters_rarch[MAX_COUNTERS]; -static struct retro_perf_counter *perf_counters_libretro[MAX_COUNTERS]; -static unsigned perf_ptr_rarch; -static unsigned perf_ptr_libretro; - -struct retro_perf_counter **retro_get_perf_counter_rarch(void) -{ - return perf_counters_rarch; -} - -struct retro_perf_counter **retro_get_perf_counter_libretro(void) -{ - return perf_counters_libretro; -} - -unsigned retro_get_perf_count_rarch(void) -{ - return perf_ptr_rarch; -} - -unsigned retro_get_perf_count_libretro(void) -{ - return perf_ptr_libretro; -} - -void rarch_perf_register(struct retro_perf_counter *perf) -{ - if ( - !runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) - || perf->registered - || perf_ptr_rarch >= MAX_COUNTERS - ) - return; - - perf_counters_rarch[perf_ptr_rarch++] = perf; - perf->registered = true; -} - -void retro_perf_register(struct retro_perf_counter *perf) -{ - if (perf->registered || perf_ptr_libretro >= MAX_COUNTERS) - return; - - perf_counters_libretro[perf_ptr_libretro++] = perf; - perf->registered = true; -} - -void retro_perf_clear(void) -{ - perf_ptr_libretro = 0; - memset(perf_counters_libretro, 0, sizeof(perf_counters_libretro)); -} - -static void log_counters(struct retro_perf_counter **counters, unsigned num) -{ - unsigned i; - for (i = 0; i < num; i++) - { - if (counters[i]->call_cnt) - { - RARCH_LOG(PERF_LOG_FMT, - counters[i]->ident, - (unsigned long long)counters[i]->total / - (unsigned long long)counters[i]->call_cnt, - (unsigned long long)counters[i]->call_cnt); - } - } -} - -void rarch_perf_log(void) -{ - if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL)) - return; - - RARCH_LOG("[PERF]: Performance counters (RetroArch):\n"); - log_counters(perf_counters_rarch, perf_ptr_rarch); -} - -void retro_perf_log(void) -{ - RARCH_LOG("[PERF]: Performance counters (libretro):\n"); - log_counters(perf_counters_libretro, perf_ptr_libretro); -} - /** * retro_get_perf_counter: * @@ -652,30 +568,3 @@ uint64_t retro_get_cpu_features(void) return cpu; } - -int rarch_perf_init(struct retro_perf_counter *perf, const char *name) -{ - perf->ident = name; - - if (!perf->registered) - rarch_perf_register(perf); - - return 0; -} - -void retro_perf_start(struct retro_perf_counter *perf) -{ - if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) || !perf) - return; - - perf->call_cnt++; - perf->start = retro_get_perf_counter(); -} - -void retro_perf_stop(struct retro_perf_counter *perf) -{ - if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) || !perf) - return; - - perf->total += retro_get_perf_counter() - perf->start; -} diff --git a/performance.h b/performance.h index 3f941d8957..71b56a00f1 100644 --- a/performance.h +++ b/performance.h @@ -25,27 +25,6 @@ extern "C" { #endif -#ifndef MAX_COUNTERS -#define MAX_COUNTERS 64 -#endif - -struct retro_perf_counter **retro_get_perf_counter_rarch(void); - -struct retro_perf_counter **retro_get_perf_counter_libretro(void); - -unsigned retro_get_perf_count_rarch(void); - -unsigned retro_get_perf_count_libretro(void); - -/* - * retro_get_perf_counter: - * - * Gets performance counter. - * - * Returns: performance counter. - **/ -retro_perf_tick_t retro_get_perf_counter(void); - /** * retro_get_time_usec: * @@ -54,35 +33,6 @@ retro_perf_tick_t retro_get_perf_counter(void); **/ retro_time_t retro_get_time_usec(void); -void retro_perf_register(struct retro_perf_counter *perf); - -/* Same as retro_perf_register, just for libretro cores. */ -void retro_perf_register(struct retro_perf_counter *perf); - -void retro_perf_clear(void); - -void retro_perf_log(void); - -void rarch_perf_log(void); - -int rarch_perf_init(struct retro_perf_counter *perf, const char *name); - -/** - * retro_perf_start: - * @perf : pointer to performance counter - * - * Start performance counter. - **/ -void retro_perf_start(struct retro_perf_counter *perf); - -/** - * retro_perf_stop: - * @perf : pointer to performance counter - * - * Stop performance counter. - **/ -void retro_perf_stop(struct retro_perf_counter *perf); - /** * retro_get_cpu_features: * diff --git a/performance_counters.c b/performance_counters.c new file mode 100644 index 0000000000..ce8e4d248a --- /dev/null +++ b/performance_counters.c @@ -0,0 +1,145 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include + +#include "performance_counters.h" + +#include "general.h" +#include "compat/strl.h" +#include "verbosity.h" + +#ifdef _WIN32 +#define PERF_LOG_FMT "[PERF]: Avg (%s): %I64u ticks, %I64u runs.\n" +#else +#define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n" +#endif + +#if !defined(_WIN32) && !defined(RARCH_CONSOLE) +#include +#endif + +static struct retro_perf_counter *perf_counters_rarch[MAX_COUNTERS]; +static struct retro_perf_counter *perf_counters_libretro[MAX_COUNTERS]; +static unsigned perf_ptr_rarch; +static unsigned perf_ptr_libretro; + +struct retro_perf_counter **retro_get_perf_counter_rarch(void) +{ + return perf_counters_rarch; +} + +struct retro_perf_counter **retro_get_perf_counter_libretro(void) +{ + return perf_counters_libretro; +} + +unsigned retro_get_perf_count_rarch(void) +{ + return perf_ptr_rarch; +} + +unsigned retro_get_perf_count_libretro(void) +{ + return perf_ptr_libretro; +} + +void rarch_perf_register(struct retro_perf_counter *perf) +{ + if ( + !runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) + || perf->registered + || perf_ptr_rarch >= MAX_COUNTERS + ) + return; + + perf_counters_rarch[perf_ptr_rarch++] = perf; + perf->registered = true; +} + +void retro_perf_register(struct retro_perf_counter *perf) +{ + if (perf->registered || perf_ptr_libretro >= MAX_COUNTERS) + return; + + perf_counters_libretro[perf_ptr_libretro++] = perf; + perf->registered = true; +} + +void retro_perf_clear(void) +{ + perf_ptr_libretro = 0; + memset(perf_counters_libretro, 0, sizeof(perf_counters_libretro)); +} + +static void log_counters(struct retro_perf_counter **counters, unsigned num) +{ + unsigned i; + for (i = 0; i < num; i++) + { + if (counters[i]->call_cnt) + { + RARCH_LOG(PERF_LOG_FMT, + counters[i]->ident, + (unsigned long long)counters[i]->total / + (unsigned long long)counters[i]->call_cnt, + (unsigned long long)counters[i]->call_cnt); + } + } +} + +void rarch_perf_log(void) +{ + if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL)) + return; + + RARCH_LOG("[PERF]: Performance counters (RetroArch):\n"); + log_counters(perf_counters_rarch, perf_ptr_rarch); +} + +void retro_perf_log(void) +{ + RARCH_LOG("[PERF]: Performance counters (libretro):\n"); + log_counters(perf_counters_libretro, perf_ptr_libretro); +} + +int rarch_perf_init(struct retro_perf_counter *perf, const char *name) +{ + perf->ident = name; + + if (!perf->registered) + rarch_perf_register(perf); + + return 0; +} + +void retro_perf_start(struct retro_perf_counter *perf) +{ + if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) || !perf) + return; + + perf->call_cnt++; + perf->start = retro_get_perf_counter(); +} + +void retro_perf_stop(struct retro_perf_counter *perf) +{ + if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) || !perf) + return; + + perf->total += retro_get_perf_counter() - perf->start; +} diff --git a/performance_counters.h b/performance_counters.h new file mode 100644 index 0000000000..c15cc7881a --- /dev/null +++ b/performance_counters.h @@ -0,0 +1,83 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef _PERFORMANCE_COUNTERS_H +#define _PERFORMANCE_COUNTERS_H + +#include + +#include "libretro.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef MAX_COUNTERS +#define MAX_COUNTERS 64 +#endif + +struct retro_perf_counter **retro_get_perf_counter_rarch(void); + +struct retro_perf_counter **retro_get_perf_counter_libretro(void); + +unsigned retro_get_perf_count_rarch(void); + +unsigned retro_get_perf_count_libretro(void); + +/* + * retro_get_perf_counter: + * + * Gets performance counter. + * + * Returns: performance counter. + **/ +retro_perf_tick_t retro_get_perf_counter(void); + +void retro_perf_register(struct retro_perf_counter *perf); + +/* Same as retro_perf_register, just for libretro cores. */ +void retro_perf_register(struct retro_perf_counter *perf); + +void retro_perf_clear(void); + +void retro_perf_log(void); + +void rarch_perf_log(void); + +int rarch_perf_init(struct retro_perf_counter *perf, const char *name); + +/** + * retro_perf_start: + * @perf : pointer to performance counter + * + * Start performance counter. + **/ +void retro_perf_start(struct retro_perf_counter *perf); + +/** + * retro_perf_stop: + * @perf : pointer to performance counter + * + * Stop performance counter. + **/ +void retro_perf_stop(struct retro_perf_counter *perf); + +#ifdef __cplusplus +} +#endif + +#endif +