From 7f339f1358731da493ca18dbb0a700671df69e1b Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sun, 2 Apr 2017 10:31:06 +0200 Subject: [PATCH] Becnh dict+mempool --- bench/bench-mlib.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bench/bench-mlib.c b/bench/bench-mlib.c index dea8095a..260bb548 100644 --- a/bench/bench-mlib.c +++ b/bench/bench-mlib.c @@ -132,11 +132,18 @@ static void test_rbtree(size_t n) /********************************************************************************************/ +#ifdef USE_MEMPOOL +DICT_DEF2(ulong, unsigned long, M_OPLIST_CAT((MEMPOOL(dict_mpool), MEMPOOL_LINKAGE(static)),M_DEFAULT_OPLIST), unsigned long, M_DEFAULT_OPLIST) +#else DICT_DEF2(ulong, unsigned long, M_DEFAULT_OPLIST, unsigned long, M_DEFAULT_OPLIST) +#endif static void test_dict(unsigned long n) { +#ifdef USE_MEMPOOL + mempool_list_dict_pair_ulong_init(dict_mpool); +#endif rand_init(); M_LET(dict, DICT_OPLIST(ulong)) { for (size_t i = 0; i < n; i++) { @@ -151,6 +158,9 @@ test_dict(unsigned long n) } g_result = s; } +#ifdef USE_MEMPOOL + mempool_list_dict_pair_ulong_clear(dict_mpool); +#endif } /********************************************************************************************/ @@ -165,11 +175,18 @@ static size_t char_hash(const char_array_t a) { return m_core_hash (a, strlen(a) // NOTE: Can't set OPLIST as a macro! #define CHAR_OPLIST (INIT(char_init), INIT_SET(char_set), SET(char_set), CLEAR(char_init), HASH(char_hash), EQUAL(char_equal_p)) +#ifdef USE_MEMPOOL +DICT_DEF2(char, char_array_t, M_OPLIST_CAT((MEMPOOL(dict_mpool2), MEMPOOL_LINKAGE(static)),CHAR_OPLIST), char_array_t, CHAR_OPLIST) +#else DICT_DEF2(char, char_array_t, CHAR_OPLIST, char_array_t, CHAR_OPLIST) +#endif static void test_dict_big(unsigned long n) { +#ifdef USE_MEMPOOL + mempool_list_dict_pair_char_init(dict_mpool2); +#endif rand_init(); M_LET(dict, DICT_OPLIST(char)) { for (size_t i = 0; i < n; i++) { @@ -188,6 +205,9 @@ test_dict_big(unsigned long n) } g_result = s; } +#ifdef USE_MEMPOOL + mempool_list_dict_pair_char_clear(dict_mpool2); +#endif } /********************************************************************************************/