Skip to content

Commit

Permalink
Add benchmark for verstable
Browse files Browse the repository at this point in the history
  • Loading branch information
P-p-H-d committed Dec 12, 2023
1 parent ec0a082 commit e50fdc8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bench/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,14 @@ bench-CC0:
@./bench-CC.exe 40
@./bench-CC.exe 41

# VERSTABLE shall point to the source directory of VERSTABLE (where the headers are)
bench-verstable:
@if test -n "$${VERSTABLE}" ; then $(MAKE) bench-verstable0 ; else echo "Nothing to be done for VERSTABLE." ; fi

bench-verstable0:
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I $${VERSTABLE}/ bench-verstable.c common.c -o bench-verstable.exe
@./bench-verstable.exe 40

############################################################################

bench-mlib-json: bench-mlib
Expand Down
48 changes: 48 additions & 0 deletions bench/bench-verstable.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#define NDEBUG

#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>

#include "common.h"

#define NAME umap_ulong
#define KEY_TY unsigned long
#define VAL_TY unsigned long
#include "verstable.h"

static void
test_dict(size_t n)
{
umap_ulong dict;
umap_ulong_init(&dict);

for (size_t i = 0; i < n; i++) {
unsigned long value = rand_get();
unsigned long key = rand_get();
umap_ulong_insert(&dict, key, value);
}
rand_init();
unsigned int s = 0;
for (size_t i = 0; i < n; i++) {
umap_ulong_itr it = umap_ulong_get(&dict, rand_get());
if (!umap_ulong_is_end(it) )
s += it.data->val;
}
g_result = s;

umap_ulong_cleanup(&dict);
}

/********************************************************************************************/

const config_func_t table[] = {
{ 40, "dict", 1000000, 0, test_dict, 0},
};

int main(int argc, const char *argv[])
{
test("CTL", numberof(table), table, argc, argv);
exit(0);
}

0 comments on commit e50fdc8

Please sign in to comment.