forked from enlightenment/efl
Add option to report stringshare usage (E17 use around 10000 differents strings).
SVN revision: 36658
This commit is contained in:
parent
ed012620d1
commit
d905ee9bda
|
@ -83,6 +83,25 @@ if test "x${enable_default_mempool}" = "xyes" ; then
|
|||
fi
|
||||
AC_SUBST(EINA_DEFAULT_MEMPOOL)
|
||||
|
||||
# Report stringshare usage
|
||||
AC_ARG_ENABLE([stringshare-usage],
|
||||
[AC_HELP_STRING([--enable-stringshare-usage], [Report stringshare usage on stringshare shutdown])],
|
||||
[
|
||||
if test "x${enableval}" = "xyes"; then
|
||||
enable_stringshare_usage="yes"
|
||||
else
|
||||
enable_stringshare_usage="no"
|
||||
fi
|
||||
],
|
||||
[enable_stringshare_usage="no"]
|
||||
)
|
||||
AC_MSG_CHECKING([whether to report stringshare usage])
|
||||
AC_MSG_RESULT([${enable_stringshare_usage}])
|
||||
|
||||
if test "x${enable_stringshare_usage}" = "xyes"; then
|
||||
AC_DEFINE(EINA_STRINGSHARE_USAGE, 1, [Report Eina stringshare usage pattern])
|
||||
fi
|
||||
|
||||
# Ememoa memory pool
|
||||
|
||||
AC_ARG_ENABLE([ememoa],
|
||||
|
@ -341,6 +360,8 @@ echo " Thread Support.......: ${have_pthread}"
|
|||
echo
|
||||
echo " Magic debug..........: ${enable_magic_debug}"
|
||||
echo
|
||||
echo " Report string usage..: ${enable_stringshare_usage}"
|
||||
echo
|
||||
echo " Default mempool......: ${enable_default_mempool}"
|
||||
echo
|
||||
echo " Memory pool:"
|
||||
|
|
|
@ -115,6 +115,10 @@ struct _Eina_Stringshare_Head
|
|||
|
||||
int hash;
|
||||
|
||||
#ifdef EINA_STRINGSHARE_USAGE
|
||||
int population;
|
||||
#endif
|
||||
|
||||
Eina_Stringshare_Node *head;
|
||||
};
|
||||
|
||||
|
@ -133,6 +137,12 @@ struct _Eina_Stringshare_Node
|
|||
static Eina_Stringshare *share = NULL;
|
||||
static int _eina_stringshare_init_count = 0;
|
||||
|
||||
#ifdef EINA_STRINGSHARE_USAGE
|
||||
static int population = 0;
|
||||
static int max_population = 0;
|
||||
static int max_node_population = 0;
|
||||
#endif
|
||||
|
||||
static int
|
||||
_eina_stringshare_cmp(const Eina_Stringshare_Head *ed, const int *hash, __UNUSED__ int length, __UNUSED__ void *data)
|
||||
{
|
||||
|
@ -263,6 +273,12 @@ eina_stringshare_init()
|
|||
EAPI int
|
||||
eina_stringshare_shutdown()
|
||||
{
|
||||
#ifdef EINA_STRINGSHARE_USAGE
|
||||
fprintf(stderr, "eina stringshare statistic:\n");
|
||||
fprintf(stderr, " * maximum shared strings : %i\n", max_population);
|
||||
fprintf(stderr, " * maximum shared strings per node : %i\n", max_node_population);
|
||||
#endif
|
||||
|
||||
--_eina_stringshare_init_count;
|
||||
if (!_eina_stringshare_init_count)
|
||||
{
|
||||
|
@ -275,6 +291,12 @@ eina_stringshare_shutdown()
|
|||
}
|
||||
MAGIC_FREE(share);
|
||||
|
||||
#ifdef EINA_STRINGSHARE_USAGE
|
||||
population = 0;
|
||||
max_node_population = 0;
|
||||
max_population = 0;
|
||||
#endif
|
||||
|
||||
eina_magic_string_shutdown();
|
||||
eina_error_shutdown();
|
||||
}
|
||||
|
@ -322,6 +344,10 @@ eina_stringshare_add(const char *str)
|
|||
ed->hash = hash;
|
||||
ed->head = NULL;
|
||||
|
||||
#ifdef EINA_STRINGSHARE_USAGE
|
||||
ed->population = 0;
|
||||
#endif
|
||||
|
||||
share->buckets[hash_num] = (Eina_Stringshare_Head*) eina_rbtree_inline_insert((Eina_Rbtree*) share->buckets[hash_num],
|
||||
EINA_RBTREE_GET(ed),
|
||||
EINA_RBTREE_CMP_NODE_CB(_eina_stringshare_node), NULL);
|
||||
|
@ -370,6 +396,13 @@ eina_stringshare_add(const char *str)
|
|||
nel->next = ed->head;
|
||||
ed->head = nel;
|
||||
|
||||
#ifdef EINA_STRINGSHARE_USAGE
|
||||
ed->population++;
|
||||
population++;
|
||||
if (population > max_population) max_population = population;
|
||||
if (ed->population > max_node_population) max_node_population = ed->population;
|
||||
#endif
|
||||
|
||||
return el_str;
|
||||
}
|
||||
|
||||
|
@ -420,6 +453,11 @@ eina_stringshare_del(const char *str)
|
|||
if (el->begin == EINA_FALSE)
|
||||
MAGIC_FREE(el);
|
||||
|
||||
#ifdef EINA_STRINGSHARE_USAGE
|
||||
ed->population--;
|
||||
population--;
|
||||
#endif
|
||||
|
||||
if (ed->head == NULL)
|
||||
{
|
||||
share->buckets[hash_num] = (Eina_Stringshare_Head*) eina_rbtree_inline_remove(EINA_RBTREE_GET(share->buckets[hash_num]),
|
||||
|
|
|
@ -141,6 +141,9 @@ START_TEST(eina_stringshare_collision)
|
|||
for (i = 0; i < 200; ++i)
|
||||
eina_stringshare_del(eina_array_data_get(ea, i));
|
||||
|
||||
for (i = 0; i < 1000; ++i)
|
||||
eina_stringshare_del(eina_array_pop(ea));
|
||||
|
||||
eina_stringshare_shutdown();
|
||||
|
||||
eina_array_free(ea);
|
||||
|
|
Loading…
Reference in New Issue