Add linear bench

This commit is contained in:
Patrick Pelissier committed 2019-10-14 21:29:27 +02:00
1 parent 00b875ea53
commit 3b647b982f
2 files changed
+20

No files matched your search

+1
View File
@@ -194,6 +194,7 @@ bench-flathashmap0:
$(CXX) -std=c++14 $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -I "$${FLATHASHMAP}" bench-flathashmap.cpp -o bench-flathashmap.exe
@./bench-flathashmap.exe 41
@./bench-flathashmap.exe 42
@./bench-flathashmap.exe 46
@./bench-flathashmap.exe 43
# HOPSCOTCHMAP shall point to the directory where the source are
+19
View File
@@ -42,6 +42,23 @@ test_dict2(size_t n)
g_result = s;
}
static void
test_dict2_linear(size_t n)
{
flat_hash_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++) {
flat_hash_map<unsigned long, unsigned long>::iterator it = dict.find(i);
if (it != dict.end())
s += it->second;
}
g_result = s;
}
/********************************************************************************************/
struct char_array_s {
char a[256];
@@ -113,6 +130,8 @@ int main(int argc, const char *argv[])
int n = (argc > 1) ? atoi(argv[1]) : 0;
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)