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],
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:"
int hash;
+#ifdef EINA_STRINGSHARE_USAGE
+ int population;
+#endif
+
Eina_Stringshare_Node *head;
};
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)
{
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)
{
}
MAGIC_FREE(share);
+#ifdef EINA_STRINGSHARE_USAGE
+ population = 0;
+ max_node_population = 0;
+ max_population = 0;
+#endif
+
eina_magic_string_shutdown();
eina_error_shutdown();
}
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);
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;
}
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]),