Add linear hash map bench

This commit is contained in:
Patrick Pelissier committed 2019-10-14 20:57:29 +02:00
1 parent 545fc4d93c
commit 00b875ea53
3 files changed
+43

No files matched your search

+3
View File
@@ -47,6 +47,7 @@ bench-mlib:
@./bench-mlib.exe 40
@./bench-mlib.exe 41
@./bench-mlib.exe 42
@./bench-mlib.exe 46
@./bench-mlib.exe 43
@./bench-mlib.exe 50
@./bench-mlib.exe 51
@@ -61,6 +62,7 @@ bench-mlib-mempool:
@./bench-mlib-mempool.exe 40
@./bench-mlib-mempool.exe 41
@./bench-mlib-mempool.exe 42
@./bench-mlib-mempool.exe 46
@./bench-mlib-mempool.exe 43
@./bench-mlib-mempool.exe 50
@./bench-mlib-mempool.exe 51
@@ -83,6 +85,7 @@ bench-stl:
@./bench-stl.exe 40
@./bench-stl.exe 41
@./bench-stl.exe 42
@./bench-stl.exe 46
@./bench-stl.exe 43
@./bench-stl.exe 50
@./bench-stl.exe 51
+20
View File
@@ -220,6 +220,24 @@ test_dict_oa(size_t n)
}
}
static void
test_dict_oa_linear(size_t n)
{
M_LET(dict, DICT_OPLIST(dict_oa_ulong)) {
for (size_t i = 0; i < n; i++) {
dict_oa_ulong_set_at(dict, i, rand_get() );
}
rand_init();
unsigned int s = 0;
for (size_t i = 0; i < n; i++) {
unsigned long *p = dict_oa_ulong_get(dict, i);
if (p)
s += *p;
}
g_result = s;
}
}
/********************************************************************************************/
typedef char char_array_t[256];
@@ -809,6 +827,8 @@ int main(int argc, const char *argv[])
test_function("Dict time", 1000000, test_dict);
if (n == 42)
test_function("DictOA time", 1000000, test_dict_oa);
if (n == 46)
test_function("DictOA+l time", 1000000, test_dict_oa_linear);
if (n == 41)
test_function("DictB time", 1000000, test_dict_big);
if (n == 43)
+20
View File
@@ -110,6 +110,24 @@ test_dict2(size_t n)
g_result = s;
}
static void
test_dict2_linear(size_t n)
{
unordered_map<unsigned long, unsigned long> dict;
for (size_t i = 0; i < n; i++) {
dict[i] = rand_get();
}
rand_init();
unsigned int s = 0;
for (size_t i = 0; i < n; i++) {
unordered_map<unsigned long, unsigned long>::iterator it = dict.find(i);
if (it != dict.end())
s += it->second;
}
g_result = s;
}
/********************************************************************************************/
struct char_array_s {
@@ -233,6 +251,8 @@ int main(int argc, const char *argv[])
test_function("Dict(m)time", 1000000, test_dict1);
if (n == 42)
test_function("Dict(u)time", 1000000, test_dict2);
if (n == 46)
test_function("Dict(u+l)time", 1000000, test_dict2_linear);
if (n == 41)
test_function("DictB time", 1000000, test_dict_big);
if (n == 43)