Add bench for M*Lib with MEMPOOL usage.

This commit is contained in:
Patrick Pelissier committed 2017-04-01 13:59:55 +02:00
1 parent aee837ea37
commit a876a1d4f1
2 files changed
+22 -1

No files matched your search

+10 -1
View File
@@ -3,7 +3,7 @@ CXX=c++ -std=c++11
CFLAGS=-O2 -march=native -Wall
CPPFLAGS=-I..
all: bench-mlib bench-stl bench-klib bench-qt bench-glib bench-libdynamic
all: bench-mlib bench-mlib-mempool bench-stl bench-klib bench-qt bench-glib bench-libdynamic
bench-mlib:
$(CC) $(CFLAGS) $(CPPFLAGS) bench-mlib.c -o bench-mlib.exe
@@ -14,6 +14,15 @@ bench-mlib:
@./bench-mlib.exe 6
@./bench-mlib.exe 7
bench-mlib-mempool:
$(CC) $(CFLAGS) $(CPPFLAGS) bench-mlib.c -DUSE_MEMPOOL -o bench-mlib-mempool.exe
@./bench-mlib-mempool.exe 1
@./bench-mlib-mempool.exe 2
@./bench-mlib-mempool.exe 3
@./bench-mlib-mempool.exe 4
@./bench-mlib-mempool.exe 6
@./bench-mlib-mempool.exe 7
bench-stl:
$(CXX) $(CFLAGS) $(CPPFLAGS) bench-stl.cpp -o bench-stl.exe
@./bench-stl.exe 1
+12
View File
@@ -12,6 +12,7 @@
#include "m-rbtree.h"
#include "m-dict.h"
#include "m-algo.h"
#include "m-mempool.h"
unsigned long g_result;
@@ -67,11 +68,19 @@ static void test_array(size_t n)
/********************************************************************************************/
// Two benched mode: with or without mempool
#ifdef USE_MEMPOOL
LIST_DEF(uint, unsigned int, (MEMPOOL( list_mpool), MEMPOOL_LINKAGE(static)))
#else
LIST_DEF(uint, unsigned int)
#endif
static void test_list (size_t n)
{
rand_init();
#ifdef USE_MEMPOOL
mempool_list_uint_init(list_mpool);
#endif
M_LET(a1, a2, LIST_OPLIST(uint)) {
for(size_t i = 0; i < n; i++) {
list_uint_push_back(a1, rand_get() );
@@ -84,6 +93,9 @@ static void test_list (size_t n)
}
g_result = s;
}
#ifdef USE_MEMPOOL
mempool_list_uint_clear(list_mpool);
#endif
}
/********************************************************************************************/