update benchmark code to allow for more comparisons

This commit is contained in:
greg
2019-04-05 21:00:01 -04:00
parent efde045919
commit 13681b0d58
3 changed files with 17 additions and 8 deletions
+7 -3
View File
@@ -4,7 +4,7 @@ CXX=CL -EHsc -DNDEBUG -Fo$@ -O2
ABSEIL_LIBS=absl_bad_optional_access.lib absl_bad_variant_access.lib absl_base.lib absl_demangle_internal.lib absl_hash.lib absl_int128.lib absl_internal_bad_any_cast_impl.lib absl_internal_city.lib absl_internal_civil_time.lib absl_internal_debugging_internal.lib absl_internal_graphcycles_internal.lib absl_internal_hashtablez_sampler.lib absl_internal_malloc_internal.lib absl_internal_spinlock_wait.lib absl_internal_strings_internal.lib absl_internal_throw_delegate.lib absl_internal_time_zone.lib absl_optional.lib absl_raw_hash_set.lib absl_stacktrace.lib absl_strings.lib absl_symbolize.lib absl_synchronization.lib absl_time.lib
PROGS = stl_unordered_map sparsepp phmap abseil_flat abseil_parallel_flat
PROGS = stl_unordered_map sparsepp phmap abseil_flat abseil_parallel_flat phmap_flat
BUILD_PROGS = $(addprefix build/,$(PROGS))
SIZE = 100000000
ABSEIL = ../../abseil-cpp
@@ -24,6 +24,9 @@ build/sparsepp: bench.cc Makefile
build/phmap: bench.cc Makefile $(PHMAP_SRC)/phmap.h
$(CXX) -DPHMAP -I.. bench.cc /MD -o $@
build/phmap_flat: bench.cc Makefile $(PHMAP_SRC)/phmap.h
$(CXX) -DPHMAP_FLAT -I.. bench.cc /MD -o $@
build/abseil_flat: bench.cc Makefile
$(CXX) -DABSEIL_FLAT -I$(ABSEIL) bench.cc /MD -o $@ /link /LIBPATH:$(ABSEIL)/build/lib ${ABSEIL_LIBS}
@@ -35,9 +38,10 @@ progs: $(BUILD_PROGS)
test: builddir progs
-rm -f output
#./build/stl_unordered_map $(SIZE) random >> output
#./build/abseil_flat $(SIZE) random >> output
./build/phmap $(SIZE) random >> output
#./build/sparsepp $(SIZE) random >> output
#./build/abseil_flat $(SIZE) random >> output
#./build/phmap_flat $(SIZE) random >> output
./build/phmap $(SIZE) random >> output
./build/abseil_parallel_flat $(SIZE) random >> output
python make_chart_data.py < output
+8 -3
View File
@@ -13,6 +13,11 @@
#include "absl/container/flat_hash_map.h"
#define MAPNAME absl::flat_hash_map
#define EXTRAARGS
#elif defined(PHMAP_FLAT)
#include "parallel_hashmap/phmap.h"
#define MAPNAME phmap::flat_hash_map
#define NMSP phmap
#define EXTRAARGS
#elif defined(ABSEIL_PARALLEL_FLAT) || defined(PHMAP)
#if defined(ABSEIL_PARALLEL_FLAT)
#include "absl/container/parallel_flat_hash_map.h"
@@ -24,7 +29,7 @@
#define NMSP phmap
#endif
#define MT_SUPPORT 1
#define MT_SUPPORT 0
#if MT_SUPPORT == 1
// create the parallel_flat_hash_map without internal mutexes, for when
// we programatically ensure that each thread uses different internal submaps
@@ -202,7 +207,7 @@ void _fill_random_inner_mt(int64_t cnt, HT &hash, RSU &rsu)
auto thread_fn = [&hash, cnt, num_threads](int64_t thread_idx, RSU rsu) {
#if MT_SUPPORT
typename HT::hasher hasher; // get hasher object from the hash table
typename HT::hasher hasher; // get hasher object from the hash table [greg] todo provide hash fn
size_t modulo = hash.subcnt() / num_threads; // subcnt() returns the number of submaps
for (int64_t i=0; i<cnt; ++i) // iterate over all values
@@ -359,7 +364,7 @@ int main(int argc, char ** argv)
srand(1); // for a fair/deterministic comparison
Timer timer(true);
#ifdef MT_SUPPORT
#if MT_SUPPORT
if (!strcmp(program_slug,"absl::parallel_flat_hash_map") ||
!strcmp(program_slug,"phmap::parallel_flat_hash_map"))
program_slug = xstr(MAPNAME) "_mt";
+2 -2
View File
@@ -44,9 +44,9 @@ proper_names = {
'std::unordered_map': 'std::unordered_map (1 thread)',
'spp::sparse_hash_map': 'sparsepp (1 thread, use_spp_alloc)',
'absl::flat_hash_map': 'absl::flat_hash_map (1 thread)',
'phmap::flat_hash_map': 'phmap::flat_hash_map (1 thread)',
'phmap::flat_hash_map': 'phmap::flat_hash_map',
'phmap::parallel_flat_hash_map': 'phmap::parallel_flat_hash_map (1 thread)',
'phmap::parallel_flat_hash_map_mt': 'phmap::parallel_flat_hash_map (8 thread8)',
'phmap::parallel_flat_hash_map_mt': 'phmap::parallel_flat_hash_map (8 thread)',
'absl::parallel_flat_hash_map': 'absl::parallel_flat_hash_map (1 thread)',
'absl::parallel_flat_hash_map_mt': 'absl::parallel_flat_hash_map (8 threads)',
'phmap::parallel_flat_hash_map_4': 'phmap::parallel_flat_hash_map (N=4, 8 threads)',