Complete bench-verstable with bench on big structure

This commit is contained in:
Patrick Pelissier committed 2023-12-13 19:35:08 +01:00
1 parent e50fdc82ef
commit 6a5c136c72
2 files changed
+47

No files matched your search

+1
View File
@@ -406,6 +406,7 @@ bench-verstable:
bench-verstable0:
$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I $${VERSTABLE}/ bench-verstable.c common.c -o bench-verstable.exe
@./bench-verstable.exe 40
@./bench-verstable.exe 41
############################################################################
+46
View File
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdbool.h>
#include "m-core.h"
#include "common.h"
#define NAME umap_ulong
@@ -36,8 +37,53 @@ test_dict(size_t n)
/********************************************************************************************/
#ifndef CHAR_ARRAY_SIZE
#define CHAR_ARRAY_SIZE 256
#endif
typedef char char_array_t[CHAR_ARRAY_SIZE];
typedef struct { char_array_t a; } char_encap;// Cannot use char_array_t directly
static bool char_equal_p (const char_encap a, const char_encap b) { return strcmp(a.a,b.a)==0; }
static size_t char_hash(const char_encap a) { return m_core_hash (a.a, strlen(a.a)); }
#define NAME umap_char_array
#define KEY_TY char_encap
#define VAL_TY char_encap
#define HASH_FN char_hash
#define CMPR_FN char_equal_p
#include "verstable.h"
static void
test_dict_big(size_t n)
{
umap_char_array dict;
umap_char_array_init(&dict);
for (size_t i = 0; i < n; i++) {
char_encap s1, s2;
sprintf(s1.a, "%u", rand_get());
sprintf(s2.a, "%u", rand_get());
umap_char_array_insert(&dict, s1, s2);
}
rand_init();
unsigned int s = 0;
for (size_t i = 0; i < n; i++) {
char_encap s1;
sprintf(s1.a, "%u", rand_get());
umap_char_array_itr it = umap_char_array_get(&dict, s1);
if (!umap_char_array_is_end(it) )
s ++;
}
g_result = s;
umap_char_array_cleanup(&dict);
}
/********************************************************************************************/
const config_func_t table[] = {
{ 40, "dict", 1000000, 0, test_dict, 0},
{ 41, "dictBig", 1000000, 0, test_dict_big, 0},
};
int main(int argc, const char *argv[])