Add bench of B+TREE

This commit is contained in:
Patrick Pelissier committed 2018-04-03 20:07:21 +02:00
1 parent e4cd999bd0
commit 9768b5b37a
2 files changed
+28

No files matched your search

+2
View File
@@ -36,6 +36,7 @@ bench-mlib:
@./bench-mlib.exe 10
@./bench-mlib.exe 20
@./bench-mlib.exe 30
@./bench-mlib.exe 31
@./bench-mlib.exe 40
@./bench-mlib.exe 41
@./bench-mlib.exe 42
@@ -48,6 +49,7 @@ bench-mlib-mempool:
@./bench-mlib-mempool.exe 10
@./bench-mlib-mempool.exe 20
@./bench-mlib-mempool.exe 30
@./bench-mlib-mempool.exe 31
@./bench-mlib-mempool.exe 40
@./bench-mlib-mempool.exe 41
@./bench-mlib-mempool.exe 42
+26
View File
@@ -7,6 +7,7 @@
#include "m-array.h"
#include "m-list.h"
#include "m-rbtree.h"
#include "m-bptree.h"
#include "m-dict.h"
#include "m-algo.h"
#include "m-mempool.h"
@@ -99,6 +100,29 @@ static void test_rbtree(size_t n)
/********************************************************************************************/
BPTREE_DEF(bptree_ulong, 21, unsigned long, M_DEFAULT_OPLIST)
static void test_bptree(size_t n)
{
bptree_ulong_t tree;
bptree_ulong_init(tree);
// M_LET(tree, RBTREE_OPLIST(rbtree_ulong)) {
for (size_t i = 0; i < n; i++) {
bptree_ulong_push(tree, rand_get());
}
rand_init();
unsigned int s = 0;
for (size_t i = 0; i < n; i++) {
unsigned long *p = bptree_ulong_get(tree, rand_get());
if (p)
s += *p;
}
g_result = s;
bptree_ulong_clear(tree);
}
/********************************************************************************************/
#ifdef USE_MEMPOOL
DICT_DEF2(dict_ulong, unsigned long, M_OPEXTEND(M_DEFAULT_OPLIST, MEMPOOL(dict_mpool), MEMPOOL_LINKAGE(static)), unsigned long, M_DEFAULT_OPLIST)
#else
@@ -486,6 +510,8 @@ int main(int argc, const char *argv[])
test_function("Array time", 100000000, test_array);
if (n == 30)
test_function("Rbtree time", 1000000, test_rbtree);
if (n == 31)
test_function("B+tree time", 1000000, test_bptree);
if (n == 40)
test_function("Dict time", 1000000, test_dict);
if (n == 42)