diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index b3e1973062..4f64e4d302 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -4084,6 +4084,72 @@ static void menu_action_setting_disp_set_label_cheat( strlcpy(path_buf, path, path_buf_size); } +static void menu_action_setting_disp_set_label_perf_counters( + file_list_t* list, + unsigned *w, unsigned type, unsigned i, + const char *label, + char *type_str, size_t type_str_size, + const char *entry_label, + const char *path, + char *path_buf, size_t path_buf_size) +{ + const struct retro_perf_counter **counters = + (const struct retro_perf_counter **)perf_counters_rarch; + unsigned offset = type - MENU_SETTINGS_PERF_COUNTERS_BEGIN; + + *type_str = '\0'; + *w = 19; + strlcpy(path_buf, path, path_buf_size); + + if (!counters[offset]) + return; + if (!counters[offset]->call_cnt) + return; + + snprintf(type_str, type_str_size, +#ifdef _WIN32 + "%I64u ticks, %I64u runs.", +#else + "%llu ticks, %llu runs.", +#endif + ((unsigned long long)counters[offset]->total / + (unsigned long long)counters[offset]->call_cnt), + (unsigned long long)counters[offset]->call_cnt); +} + +static void menu_action_setting_disp_set_label_libretro_perf_counters( + file_list_t* list, + unsigned *w, unsigned type, unsigned i, + const char *label, + char *type_str, size_t type_str_size, + const char *entry_label, + const char *path, + char *path_buf, size_t path_buf_size) +{ + const struct retro_perf_counter **counters = + (const struct retro_perf_counter **)perf_counters_libretro; + unsigned offset = type - MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN; + + *type_str = '\0'; + *w = 19; + strlcpy(path_buf, path, path_buf_size); + + if (!counters[offset]) + return; + if (!counters[offset]->call_cnt) + return; + + snprintf(type_str, type_str_size, +#ifdef _WIN32 + "%I64u ticks, %I64u runs.", +#else + "%llu ticks, %llu runs.", +#endif + ((unsigned long long)counters[offset]->total / + (unsigned long long)counters[offset]->call_cnt), + (unsigned long long)counters[offset]->call_cnt); +} + static void menu_action_setting_disp_set_label_menu_more( file_list_t* list, unsigned *w, unsigned type, unsigned i, @@ -4915,6 +4981,14 @@ static void menu_entries_cbs_init_bind_get_string_representation(menu_file_list_ && type <= MENU_SETTINGS_CHEAT_END) cbs->action_get_representation = menu_action_setting_disp_set_label_cheat; + else if (type >= MENU_SETTINGS_PERF_COUNTERS_BEGIN + && type <= MENU_SETTINGS_PERF_COUNTERS_END) + cbs->action_get_representation = + menu_action_setting_disp_set_label_perf_counters; + else if (type >= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN + && type <= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_END) + cbs->action_get_representation = + menu_action_setting_disp_set_label_libretro_perf_counters; else { switch (type) diff --git a/settings_data.c b/settings_data.c index c6f9c8cf10..d6a2be00cf 100644 --- a/settings_data.c +++ b/settings_data.c @@ -1397,30 +1397,6 @@ static void setting_data_get_string_representation_uint(void *data, *setting->value.unsigned_integer); } -#ifdef HAVE_MENU -static void menu_common_setting_set_label_perf(char *type_str, - size_t type_str_size, unsigned *w, unsigned type, - const struct retro_perf_counter **counters, unsigned offset) -{ - if (counters[offset] && counters[offset]->call_cnt) - { - snprintf(type_str, type_str_size, -#ifdef _WIN32 - "%I64u ticks, %I64u runs.", -#else - "%llu ticks, %llu runs.", -#endif - ((unsigned long long)counters[offset]->total / - (unsigned long long)counters[offset]->call_cnt), - (unsigned long long)counters[offset]->call_cnt); - return; - } - - *type_str = '\0'; - *w = 0; -} -#endif - /** ******* LIST BUILDING HELPER FUNCTIONS ******* **/ @@ -2926,16 +2902,6 @@ void setting_data_get_label(void *data, char *type_str, else if (!strcmp(label, "remap_file_load")) fill_pathname_base(type_str, g_settings.input.remapping_path, type_str_size); - else if (type >= MENU_SETTINGS_PERF_COUNTERS_BEGIN - && type <= MENU_SETTINGS_PERF_COUNTERS_END) - menu_common_setting_set_label_perf(type_str, type_str_size, w, type, - perf_counters_rarch, - type - MENU_SETTINGS_PERF_COUNTERS_BEGIN); - else if (type >= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN - && type <= MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_END) - menu_common_setting_set_label_perf(type_str, type_str_size, w, type, - perf_counters_libretro, - type - MENU_SETTINGS_LIBRETRO_PERF_COUNTERS_BEGIN); else { rarch_setting_t *setting_data = NULL;