From e282477a21b53afae63fc13572c54f108eb00695 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Fri, 22 Sep 2006 10:11:32 +0000 Subject: [PATCH] Instrumentation so that we can test performance while of caching. SVN revision: 26022 --- .../src/lib/ecore_desktop/Ecore_Desktop.h | 20 ++++++ .../src/lib/ecore_desktop/ecore_desktop.c | 71 +++++++++++++++---- .../lib/ecore_desktop/ecore_desktop_icon.c | 23 +++++- .../lib/ecore_desktop/ecore_desktop_paths.c | 9 +++ .../lib/ecore_desktop/ecore_desktop_private.h | 3 + 5 files changed, 113 insertions(+), 13 deletions(-) diff --git a/legacy/ecore/src/lib/ecore_desktop/Ecore_Desktop.h b/legacy/ecore/src/lib/ecore_desktop/Ecore_Desktop.h index 4671541dc7..5fa5bff18a 100644 --- a/legacy/ecore/src/lib/ecore_desktop/Ecore_Desktop.h +++ b/legacy/ecore/src/lib/ecore_desktop/Ecore_Desktop.h @@ -132,6 +132,23 @@ struct _Ecore_Desktop_Tree Ecore_Desktop_Tree *parent; /* Parent if this is a child. */ }; +struct _Ecore_Desktop_Instrumentation +{ + double desktops_time; + double desktops_in_cache_time; + double desktops_not_found_time; + double icons_time; + double icons_in_cache_time; + double icons_not_found_time; + int desktops; + int desktops_in_cache; + int desktops_not_found; + int icons; + int icons_in_cache; + int icons_not_found; +}; + + # ifdef __cplusplus extern "C" { @@ -246,6 +263,9 @@ extern "C" char *ecore_desktop_home_get(void); + EAPI void ecore_desktop_instrumentation_reset(void); + EAPI void ecore_desktop_instrumentation_print(void); + # ifdef __cplusplus } # endif diff --git a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop.c b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop.c index 43909b61e7..5523c9e869 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop.c +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop.c @@ -8,13 +8,7 @@ #include #include -Ecore_List *ecore_desktop_paths_config = NULL; -Ecore_List *ecore_desktop_paths_menus = NULL; -Ecore_List *ecore_desktop_paths_directories = NULL; -Ecore_List *ecore_desktop_paths_desktops = NULL; -Ecore_List *ecore_desktop_paths_icons = NULL; -Ecore_List *ecore_desktop_paths_kde_legacy = NULL; -Ecore_List *ecore_desktop_paths_xsessions = NULL; +struct _Ecore_Desktop_Instrumentation instrumentation; extern int reject_count, not_over_count; @@ -188,19 +182,23 @@ _ecore_desktop_get(const char *file, const char *lang) struct stat st; char *value; int stated = 0; + int in_cache = 0; + double begin; + begin = ecore_time_get(); result = (Ecore_Desktop *) ecore_hash_get(desktop_cache, (char *)file); /* Check if the cache is still valid. */ if (result) { + in_cache = 1; if (stat(result->original_path, &st) >= 0) { if (st.st_mtime > result->mtime) { ecore_hash_remove(desktop_cache, result->original_path); result = NULL; - stated = 1; } + stated = 1; } } if (!result) @@ -215,10 +213,7 @@ _ecore_desktop_get(const char *file, const char *lang) result->data = ecore_desktop_ini_get(result->original_path); /* Timestamp the cache, and no need to stat the file twice if the cache was stale. */ if ((stated) || (stat(result->original_path, &st) >= 0)) - { - result->mtime = st.st_mtime; - stated = 1; - } + result->mtime = st.st_mtime; if (result->data) { result->group = @@ -499,6 +494,25 @@ _ecore_desktop_get(const char *file, const char *lang) } } } + + if (result) + { + if (in_cache) + { + instrumentation.desktops_in_cache_time += ecore_time_get() - begin; + instrumentation.desktops_in_cache++; + } + else + { + instrumentation.desktops_time += ecore_time_get() - begin; + instrumentation.desktops++; + } + } + else + { + instrumentation.desktops_not_found_time += ecore_time_get() - begin; + instrumentation.desktops_not_found++; + } return result; } @@ -972,3 +986,36 @@ ecore_desktop_merge_command(char *exec, char *params) return result; } + +EAPI void +ecore_desktop_instrumentation_reset(void) +{ + instrumentation.desktops = 0; + instrumentation.desktops_in_cache = 0; + instrumentation.desktops_not_found = 0; + instrumentation.icons = 0; + instrumentation.icons_in_cache = 0; + instrumentation.icons_not_found = 0; + instrumentation.desktops_time = 0.0; + instrumentation.desktops_in_cache_time = 0.0; + instrumentation.desktops_not_found_time = 0.0; + instrumentation.icons_time = 0.0; + instrumentation.icons_in_cache_time = 0.0; + instrumentation.icons_not_found_time = 0.0; + printf("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n"); + printf("Desktop instrumentation reset.\n"); + printf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); +} + +EAPI void +ecore_desktop_instrumentation_print(void) +{ + printf("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n"); + printf(" Found %5d desktops %2.5f (%2.6f/desktop)\n", instrumentation.desktops, instrumentation.desktops_time, instrumentation.desktops_time / instrumentation.desktops); + printf(" Found %5d desktops in cache %2.5f (%2.6f/desktop)\n", instrumentation.desktops_in_cache, instrumentation.desktops_in_cache_time, instrumentation.desktops_in_cache_time / instrumentation.desktops_in_cache); + printf("Not found %5d desktops %2.5f (%2.6f/desktop)\n", instrumentation.desktops_not_found, instrumentation.desktops_not_found_time, instrumentation.desktops_not_found_time / instrumentation.desktops_not_found); + printf(" Found %5d icons %2.5f (%2.6f/icon)\n", instrumentation.icons, instrumentation.icons_time, instrumentation.icons_time / instrumentation.icons); + printf(" Found %5d icons in cache %2.5f (%2.6f/icon)\n", instrumentation.icons_in_cache, instrumentation.icons_in_cache_time, instrumentation.icons_in_cache_time / instrumentation.icons_in_cache); + printf("Not found %5d icons %2.5f (%2.6f/icon)\n", instrumentation.icons_not_found, instrumentation.icons_not_found_time, instrumentation.icons_not_found_time / instrumentation.icons_not_found); + printf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); +} diff --git a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_icon.c b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_icon.c index e2e2c5867b..3130cd47d8 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_icon.c +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_icon.c @@ -19,7 +19,7 @@ _ecore_desktop_icon_theme_directory_destroy(Ecore_Desktop_Icon_Theme_Directory * /* FIXME: We need a way for the client to disable searching for any of these that they don't support. */ static const char *ext[] = - { ".edj", ".png", ".svgz", ".svg", ".xpm", "", NULL }; + { ".edj", ".png", ".svgz", ".svg", ".xpm", NULL }; static int init_count = 0; static Ecore_Hash *icon_theme_cache; static int loaded = 0; @@ -53,7 +53,10 @@ ecore_desktop_icon_find(const char *icon, const char *icon_size, { const char *dir = NULL, *icn; Ecore_List *icons; + int in_cache = 0; + double begin; + begin = ecore_time_get(); if (icon == NULL) return NULL; @@ -85,6 +88,24 @@ ecore_desktop_icon_find(const char *icon, const char *icon_size, } ecore_list_destroy(icons); + if (dir) + { + if (in_cache) + { + instrumentation.icons_in_cache_time += ecore_time_get() - begin; + instrumentation.icons_in_cache++; + } + else + { + instrumentation.icons_time += ecore_time_get() - begin; + instrumentation.icons++; + } + } + else + { + instrumentation.icons_not_found_time += ecore_time_get() - begin; + instrumentation.icons_not_found++; + } return dir; } diff --git a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c index 4556cc9d04..c3026dd6ce 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c @@ -36,6 +36,15 @@ * and correct those guesses. */ +Ecore_List *ecore_desktop_paths_config = NULL; +Ecore_List *ecore_desktop_paths_menus = NULL; +Ecore_List *ecore_desktop_paths_directories = NULL; +Ecore_List *ecore_desktop_paths_desktops = NULL; +Ecore_List *ecore_desktop_paths_icons = NULL; +Ecore_List *ecore_desktop_paths_kde_legacy = NULL; +Ecore_List *ecore_desktop_paths_xsessions = NULL; + + static Ecore_List *_ecore_desktop_paths_get(Ecore_Desktop_Paths_Type path_type, char *before, char *env_home, char *env, char *env_home_default, diff --git a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_private.h b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_private.h index b09a745315..a6d7362e5f 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_private.h +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_private.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #define E_FN_DEL(_fn, _h) if (_h) { _fn(_h); _h = NULL; } @@ -22,6 +23,8 @@ extern Ecore_List *ecore_desktop_paths_desktops; extern Ecore_List *ecore_desktop_paths_icons; extern Ecore_List *ecore_desktop_paths_kde_legacy; extern Ecore_List *ecore_desktop_paths_xsessions; +extern struct _Ecore_Desktop_Instrumentation instrumentation; + # ifdef __cplusplus extern "C"