From 63a09f6492b022eccd1583fd9b69c450ae3a8935 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 22 Oct 2021 22:50:34 +0200 Subject: Updated shootout2_cmap.cpp and competing hashmaps. Replaced Gregs sparsepp with his parallel_hashmap as recommended by him. --- benchmarks/shootout1_cmap.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'benchmarks/shootout1_cmap.cpp') diff --git a/benchmarks/shootout1_cmap.cpp b/benchmarks/shootout1_cmap.cpp index fab25096..87790844 100644 --- a/benchmarks/shootout1_cmap.cpp +++ b/benchmarks/shootout1_cmap.cpp @@ -7,7 +7,7 @@ #include "others/robin_hood.hpp" #include "others/skarupke/bytell_hash_map.hpp" #include "others/tsl/hopscotch_map.h" -#include "others/sparsepp/spp.h" +#include "others/parallel_hashmap/phmap.h" #define PICOBENCH_IMPLEMENT_WITH_MAIN #include "picobench.hpp" @@ -19,15 +19,15 @@ template using umap = std::unordered_map; template using bmap = ska::bytell_hash_map; template using fmap = ska::flat_hash_map; template using hmap = tsl::hopscotch_map; -template using smap = spp::sparse_hash_map; -template using rmap = robin_hood::unordered_flat_map, - std::equal_to, MaxLoadFactor100>; +template using pmap = phmap::flat_hash_map; +template using rmap = robin_hood::unordered_flat_map, std::equal_to, MaxLoadFactor100>; #define DEFMAP(map, ...) \ using u##map = umap __VA_ARGS__; \ using b##map = bmap __VA_ARGS__; \ using f##map = fmap __VA_ARGS__; \ using h##map = hmap __VA_ARGS__; \ - using s##map = smap __VA_ARGS__; \ + using p##map = pmap __VA_ARGS__; \ using r##map = rmap __VA_ARGS__ @@ -119,7 +119,7 @@ PICOBENCH(ins_and_erase_i).P; PICOBENCH(ins_and_erase_i).P; PICOBENCH(ins_and_erase_i).P; PICOBENCH(ins_and_erase_i).P; -PICOBENCH(ins_and_erase_i).P; +PICOBENCH(ins_and_erase_i).P; PICOBENCH(ins_and_erase_i).P; PICOBENCH(ins_and_erase_cmap_x).P; #undef P @@ -161,7 +161,7 @@ PICOBENCH(ins_and_access_i).P; PICOBENCH(ins_and_access_i).P; PICOBENCH(ins_and_access_i).P; PICOBENCH(ins_and_access_i).P; -PICOBENCH(ins_and_access_i).P; +PICOBENCH(ins_and_access_i).P; PICOBENCH(ins_and_access_i).P; PICOBENCH(ins_and_access_cmap_i).P; #undef P @@ -169,9 +169,11 @@ PICOBENCH(ins_and_access_cmap_i).P; PICOBENCH_SUITE("Map3"); static void randomize(char* str, size_t len) { - union {uint64_t i; char c[8];} r = {.i = stc64_random()}; - for (int i = len - 7, j = 0; i < len; ++j, ++i) - str[i] = (r.c[j] & 63) + 48; + for (int k=0; k < len; ++k) { + union {uint64_t i; char c[8];} r = {.i = stc64_random()}; + for (int i=0; i<8 && k @@ -204,8 +206,9 @@ static void ins_and_access_cmap_s(picobench::state& s) picobench::scope scope(s); c_forrange (s.iterations()) { randomize(str.str, cstr_size(str)); + //if (cstr_size(str) > 30) { printf("%s\n", str.str); exit(0); } cmap_str_emplace(&map, str.str, str.str); - randomize(str.str, cstr_size(str)); + //randomize(str.str, cstr_size(str)); result += cmap_str_erase(&map, str.str); } s.set_result(result + cmap_str_size(map)); @@ -218,7 +221,7 @@ PICOBENCH(ins_and_access_s).P; PICOBENCH(ins_and_access_s).P; PICOBENCH(ins_and_access_s).P; PICOBENCH(ins_and_access_s).P; -PICOBENCH(ins_and_access_s).P; +PICOBENCH(ins_and_access_s).P; PICOBENCH(ins_and_access_s).P; PICOBENCH(ins_and_access_cmap_s).P; #undef P @@ -291,7 +294,7 @@ PICOBENCH(iterate_x).P; PICOBENCH(iterate_x).P; PICOBENCH(iterate_x).P; PICOBENCH(iterate_x).P; -PICOBENCH(iterate_x).P; +PICOBENCH(iterate_x).P; PICOBENCH(iterate_x).P; PICOBENCH(iterate_cmap_x).P; #undef P -- cgit v1.2.3