### Build Custom Pointer and llil Examples with Boost Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Builds 'custom_pointer' and 'llil' examples if Boost is found. These examples utilize Boost include directories and link against the Threads library. ```cmake if (Boost_FOUND) add_executable(ex_custom_pointer examples/custom_pointer.cc phmap.natvis) target_include_directories(ex_custom_pointer PRIVATE ${Boost_INCLUDE_DIRS}) add_executable(ex_llil examples/llil.cc phmap.natvis) target_include_directories(ex_llil PRIVATE ${Boost_INCLUDE_DIRS}) target_compile_features(ex_llil PUBLIC cxx_std_20) target_link_libraries(ex_llil Threads::Threads) endif() ``` -------------------------------- ### Add Executable for Basic Examples Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Defines executables for various example C++ files. These are standard targets for building individual examples. ```cmake add_executable(ex_allmaps examples/allmaps.cc phmap.natvis) add_executable(ex_basic examples/basic.cc phmap.natvis) add_executable(ex_bench examples/bench.cc phmap.natvis) add_executable(ex_emplace examples/emplace.cc phmap.natvis) if (MSVC) add_executable(ex_lazy_emplace_l examples/lazy_emplace_l.cc phmap.natvis) endif() add_executable(ex_serialize examples/serialize.cc phmap.natvis) #target_include_directories(ex_serialize PUBLIC $) add_executable(ex_hash_std examples/hash_std.cc phmap.natvis) add_executable(ex_hash_value examples/hash_value.cc phmap.natvis) add_executable(ex_hash examples/hash.cc phmap.natvis) add_executable(ex_two_files examples/f1.cc examples/f2.cc phmap.natvis) add_executable(ex_insert_bench examples/insert_bench.cc phmap.natvis) add_executable(ex_knucleotide examples/knucleotide.cc phmap.natvis) add_executable(ex_dump_load examples/dump_load.cc phmap.natvis) add_executable(ex_btree examples/btree.cc phmap.natvis) add_executable(ex_hash_bench examples/hash_bench.cc phmap.natvis) add_executable(ex_matt examples/matt.cc phmap.natvis) add_executable(ex_mt_word_counter examples/mt_word_counter.cc phmap.natvis) add_executable(ex_p_bench examples/p_bench.cc phmap.natvis) ``` -------------------------------- ### Build llil4map Example with OpenMP, Boost, and C++20 Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Conditionally builds the 'llil4map' example if OpenMP, Boost, and C++20 support are found. It sets include directories, compile features, and links necessary libraries. ```cmake if(POLICY CMP0167) cmake_policy(SET CMP0167 NEW) endif() find_package(OpenMP QUIET) find_package(Boost 1.70.0 QUIET) if (OpenMP_FOUND AND Boost_FOUND AND "cxx_std_20" IN_LIST CMAKE_CXX_COMPILE_FEATURES) add_executable(ex_llil4map examples/llil4map.cc phmap.natvis) target_include_directories(ex_llil4map PRIVATE ${Boost_INCLUDE_DIRS}) target_compile_features(ex_llil4map PUBLIC cxx_std_20) find_package(TBB COMPONENTS tbb) if (TBB_FOUND) target_link_libraries(ex_llil4map PRIVATE TBB::tbb) endif() target_link_libraries(ex_llil4map PRIVATE OpenMP::OpenMP_CXX) target_compile_options(ex_llil4map PRIVATE "${OpenMP_CXX_FLAGS}") file(COPY examples/llil_utils DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") endif() ``` -------------------------------- ### Configure Installation Option Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Sets the PHMAP_INSTALL option to enable or disable library installation. It defaults to ON if the current directory is the master project. ```cmake option(PHMAP_INSTALL "Enable installation" ${PHMAP_MASTER_PROJECT}) ``` -------------------------------- ### Link Threads Library to Examples Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Links the Threads library to specific example executables, ensuring thread-related functionalities are available. ```cmake target_link_libraries(ex_knucleotide Threads::Threads) target_link_libraries(ex_bench Threads::Threads) ``` -------------------------------- ### Install Library and Export Targets Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Installs the library headers and targets if PHMAP_INSTALL is enabled. It also generates a CMake config file for package management. ```cmake if(PHMAP_INSTALL) include(GNUInstallDirs) include(CMakePackageConfigHelpers) install( DIRECTORY ${PROJECT_SOURCE_DIR}/${PHMAP_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PHMAP_DIR}) install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets) export(EXPORT ${PROJECT_NAME}-targets FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake") endif() ``` -------------------------------- ### Build Options for Tests and Examples Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Defines options to control whether tests and examples are built. These options are typically controlled by the parent project's settings. ```cmake option(PHMAP_BUILD_TESTS "Whether or not to build the tests" ${PHMAP_MASTER_PROJECT}) option(PHMAP_BUILD_EXAMPLES "Whether or not to build the examples" ${PHMAP_MASTER_PROJECT}) option(PHMAP_DOWNLOAD_GTEST "Whether to download gtest or use installed version" ON) ``` -------------------------------- ### Basic Usage of flat_hash_map Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/README.md Demonstrates the creation, iteration, and modification of a `flat_hash_map` in C++. This example shows how to initialize a map with key-value pairs, iterate through its elements, add a new entry, and access an existing one. ```c++ #include #include #include using phmap::flat_hash_map; int main() { // Create an unordered_map of three strings (that map to strings) flat_hash_map email = { { "tom", "tom@gmail.com"}, { "jeff", "jk@gmail.com"}, { "jim", "jimg@microsoft.com"} }; // Iterate and print keys and values for (const auto& n : email) std::cout << n.first << "'s email is: " << n.second << "\n"; // Add a new entry email["bill"] = "bg@whatever.com"; // and print it std::cout << "bill's email is: " << email["bill"] << "\n"; return 0; } ``` -------------------------------- ### Google Test Configuration Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Configures Google Test, either by finding an installed version or downloading it. It sets up the necessary libraries for running tests. ```cmake if (PHMAP_BUILD_TESTS) if (NOT PHMAP_GTEST_LIBS) if (NOT PHMAP_DOWNLOAD_GTEST) find_package(GTest CONFIG) if (GTest_FOUND) set(PHMAP_GTEST_LIBS GTest::gmock_main) else() set(PHMAP_DOWNLOAD_GTEST ON) endif() endif() if (PHMAP_DOWNLOAD_GTEST) include(cmake/DownloadGTest.cmake) check_target(gtest) check_target(gtest_main) check_target(gmock) set(PHMAP_GTEST_LIBS gmock_main) endif() endif() enable_testing() ``` -------------------------------- ### Include Project Source Directory Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Includes the project's source directory for header files when tests or examples are being built. This allows tests and examples to find the library's headers. ```cmake if (PHMAP_BUILD_TESTS OR PHMAP_BUILD_EXAMPLES) include_directories(${PROJECT_SOURCE_DIR}) endif() ``` -------------------------------- ### Hash Function for User-Defined Class (Friend Function) Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/README.md Example of providing a hash function for a custom 'Person' class using a friend function `hash_value()`. This method is suitable when you can modify the class definition. ```c++ #include // minimal header providing phmap::HashState() #include using std::string; struct Person { bool operator==(const Person &o) const { return _first == o._first && _last == o._last && _age == o._age; } friend size_t hash_value(const Person &p) { return phmap::HashState().combine(0, p._first, p._last, p._age); } string _first; string _last; int _age; }; ``` -------------------------------- ### Hash Function for User-Defined Class (std::hash Specialization) Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/README.md Example of providing a hash function for a custom 'Person' class by specializing `std::hash`. This method is useful when you cannot modify the class definition directly. ```c++ #include // minimal header providing phmap::HashState() #include using std::string; struct Person { bool operator==(const Person &o) const { return _first == o._first && _last == o._last && _age == o._age; } string _first; string _last; int _age; }; namespace std { // inject specialization of std::hash for Person into namespace std // ---------------------------------------------------------------- template<> struct hash { std::size_t operator()(Person const &p) const { return phmap::HashState().combine(0, p._first, p._last, p._age); } }; } ``` -------------------------------- ### Create and Configure Interface Library Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Creates an INTERFACE library target for the project and specifies the source files (headers) and include directories. ```cmake add_library(${PROJECT_NAME} INTERFACE) target_sources(${PROJECT_NAME} INTERFACE ${PHMAP_HEADERS}) target_include_directories( ${PROJECT_NAME} INTERFACE $ $) ``` -------------------------------- ### Build and Run Tests with CMake Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/README.md Commands to configure, build, and run tests for the parallel-hashmap library using CMake. Ensure the build directory is created before building. ```sh cmake -DPHMAP_BUILD_TESTS=ON -DPHMAP_BUILD_EXAMPLES=ON -B build cmake --build build ctest --test-dir build ``` -------------------------------- ### Basic CMake Configuration for parallel-hashmap Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Sets up the minimum CMake version, module path, and C++ standard. It also defines the project name and version. ```cmake cmake_minimum_required(VERSION 3.13) list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(DetectVersion) if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) ## compile with C++11 support endif() if(NOT CMAKE_CXX_STANDARD_REQUIRED) set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() if(NOT DEFINED PHMAP_MASTER_PROJECT) set(PHMAP_MASTER_PROJECT OFF) if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(PHMAP_MASTER_PROJECT ON) endif() endif() project(phmap VERSION ${DETECTED_PHMAP_VERSION} LANGUAGES CXX) ``` -------------------------------- ### Runtime Chart Configuration Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/benchmark/charts-template.html Combines all settings for the runtime benchmark chart, including series, grid, axes, legend, and interactive pan/zoom options. ```javascript runtime_settings = { series: series_settings, grid: grid_settings, xaxis: xaxis_settings, yaxis: yaxis_runtime_settings, legend: legend_settings, zoom: { interactive: true }, pan: { interactive: true } }; ``` -------------------------------- ### Memory Chart Configuration Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/benchmark/charts-template.html Combines all settings for the memory benchmark chart, including series, grid, axes, legend, and interactive pan/zoom options. ```javascript memory_settings = { series: series_settings, grid: grid_settings, xaxis: xaxis_settings, yaxis: yaxis_memory_settings, legend: legend_settings, zoom: { interactive: true }, pan: { interactive: true } }; ``` -------------------------------- ### Use Abseil Hash Framework Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/README.md Include Abseil headers before phmap.h and define PHMAP_USE_ABSL_HASH to use Abseil's hash framework as the default. ```c++ #include #include "phmap.h" #define PHMAP_USE_ABSL_HASH 1 ``` -------------------------------- ### Using flat_hash_set with Custom Hashable Class Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/README.md Demonstrates creating and populating a `phmap::flat_hash_set` with a custom 'Person' class that has a `std::hash` specialization. This shows how to use custom types in phmap containers. ```c++ #include "Person.h" // defines Person with std::hash specialization #include #include int main() { // As we have defined a specialization of std::hash() for Person, // we can now create sparse_hash_set or sparse_hash_map of Persons // ---------------------------------------------------------------- phmap::flat_hash_set persons = { { "John", "Mitchell", 35 }, { "Jane", "Smith", 32 }, { "Jane", "Smith", 30 }, }; for (auto& p: persons) std::cout << p._first << ' ' << p._last << " (" << p._age << ")" << '\n'; } ``` -------------------------------- ### X-Axis Configuration Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/benchmark/charts-template.html Configures the x-axis for benchmark charts, setting tick size and a formatter to display values in millions. Used for displaying data points over a large range. ```javascript divider = 10 xaxis_settings = { tickSize: 200000000 / divider, tickFormatter: function(num, obj) { return parseInt(num/1000000) + 'M'; } }; ``` -------------------------------- ### Insert Many Integers Benchmark Data (robin_hood::hash) Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/html/bench_results/martinus_mod/InsertManyInt.html This data represents the benchmark results for inserting 100 million integers using `robin_hood::hash`. It includes execution time and memory usage for various hash map implementations. ```javascript var m1y = [ "eastl::hash_map", "boost::unordered_map 1_58", "std::unordered_map", "phmap::
parallel_node_hash_map", "boost::multi_index::
hashed_unique", "phmap::node_hash_map", "absl::node_hash_map", "spp::sparse_hash_map", "tsl::sparse_map", "folly::F14NodeMap", "robin_hood::
unordered_node_map", "folly::F14ValueMap", "absl::flat_hash_map", "phmap::
parallel_flat_hash_map
", "phmap::flat_hash_map", "tsl::hopscotch_map", "ska::bytell_hash_map", "emilib1::HashMap", "robin_hood::
unordered_flat_map
", "tsl::robin_map" ]; var data = [ // ... previous data ... { x: [47.2099, 46.459, 45.9743, 40.3984, 37.8695, 32.6551, 30.9481, 26.997, 24.7551, 22.2447, 20.2678, 15.2371, 13.8187, 13.5773, 13.1002, 12.4352, 11.5716, 10.8488, 8.66035, 6.54138], y: m1y, name: measurement_names[0] + ' (robin_hood::hash)', type: 'bar', orientation: 'h', yaxis: 'y2', marker: { color: colors[0] }, textposition: 'outside', text: [ "47.2s
4156MB", "46.5s
3777MB", "46.0s
3989MB", "40.4s
4161MB", "37.9s
3776MB", "32.7s
4161MB", "30.9s
4161MB", "27.0s
1233MB", "24.8s
1060MB
", "22.2s
4034MB", "20.3s
2296MB", "15.2s
1537MB", "13.8s
1721MB", "13.6s
1180MB
", "13.1s
1721MB", "12.4s
3064MB", "11.6s
1721MB", "10.8s
2296MB", "8.66s
1720MB
", "6.54s
4601MB
" ] } ``` -------------------------------- ### Fetch and Use parallel-hashmap with CMake Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Include the parallel-hashmap library in your CMake project using FetchContent. Adjust the GIT_TAG to your desired version. ```cmake include(FetchContent) FetchContent_Declare( parallel-hashmap GIT_REPOSITORY https://github.com/greg7mdp/parallel-hashmap.git GIT_TAG v2.0.0 # adjust tag/branch/commit as needed ) FetchContent_MakeAvailable(parallel-hashmap) ... include_directories(${parallel_hashmap_SOURCE_DIR}) ``` -------------------------------- ### Insert Many Integers Benchmark Data (absl::Hash) Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/html/bench_results/martinus_mod/InsertManyInt.html This data represents the benchmark results for inserting 100 million integers using `absl::Hash`. It includes execution time and memory usage for various hash map implementations. ```javascript var colors = Plotly.d3.scale.category10().range(); var m0y = [ "eastl::hash_map", "std::unordered_map", "boost::unordered_map 1_58", "phmap::
parallel_node_hash_map", "boost::multi_index::
hashed_unique", "absl::node_hash_map", "phmap::node_hash_map", "spp::sparse_hash_map", "tsl::sparse_map", "folly::F14NodeMap", "robin_hood::
unordered_node_map", "folly::F14ValueMap", "phmap::
parallel_flat_hash_map
", "absl::flat_hash_map", "tsl::hopscotch_map", "ska::bytell_hash_map", "phmap::flat_hash_map", "emilib1::HashMap", "robin_hood::
unordered_flat_map
", "tsl::robin_map" ]; var measurement_names = ["insert 100M int"]; var data = [ { x: [48.0243, 46.5861, 45.9632, 40.5576, 37.6103, 31.3413, 30.9575, 27.1914, 24.8357, 22.0214, 20.3446, 15.2266, 13.8475, 13.7777, 12.2028, 12.0487, 11.1835, 10.9024, 9.23316, 6.46943], y: m0y, name: measurement_names[0] + ' (absl::Hash)', type: 'bar', orientation: 'h', yaxis: 'y', marker: { color: colors[0] }, textposition: 'outside', text: [ "48.0s
4156MB", "46.6s
3989MB", "46.0s
3777MB", "40.6s
4161MB", "37.6s
3777MB", "31.3s
4161MB", "31.0s
4161MB", "27.2s
1233MB", "24.8s
1060MB
", "22.0s
4033MB", "20.3s
2296MB", "15.2s
1537MB", "13.8s
1180MB
", "13.8s
1721MB", "12.2s
3064MB", "12.0s
1721MB", "11.2s
1720MB
", "10.9s
2296MB", "9.23s
1720MB
", "6.47s
4600MB
" ] } ``` -------------------------------- ### Define Library Headers Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Lists all header files for the parallel-hashmap library. These are used to add the library's headers to the build target. ```cmake set(PHMAP_DIR parallel_hashmap) set(PHMAP_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap.h ${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap_base.h ${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap_bits.h ${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap_config.h ${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap_dump.h ${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap_fwd_decl.h ${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/phmap_utils.h ${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/meminfo.h ${CMAKE_CURRENT_SOURCE_DIR}/${PHMAP_DIR}/btree.h) ``` -------------------------------- ### InsertManyInt Benchmark Data and Layout Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/html/bench_results/martinus_mod/InsertManyInt.html This JavaScript code defines the data structure and layout for a Plotly chart visualizing InsertManyInt benchmark results. It includes data series for different hashers and specifies chart properties like titles, axes, and margins. ```javascript var data = [ { x: [ 0, 0, 47.411, 46.7195, 46.5013, 41.3253, 38.0013, 33.6112, 32.8001, 27.7112, 24.9112, 22.4112, 21.1112, 15.6112, 15.1112, 13.1112, 12.4112, 11.9112, 11.6112, 8.9911, 7.1111 ], y: m1y, name: measurement_names[0] + ' (absl::Hash)', type: 'bar', orientation: 'h', yaxis: 'y1', marker: { color: colors[0], }, textposition: 'outside', text: [ "47.4s
4156MB", "46.7s
3989MB", "46.5s
3777MB", "41.3s
4161MB", "38.0s
3777MB", "33.6s
4161MB", "32.8s
4160MB", "27.7s
1233MB", "24.9s
1060MB
", "22.4s
4033MB", "21.1s
2297MB", "15.6s
1537MB", "15.1s
1181MB
", "13.1s
1720MB", "12.4s
3064MB", "11.9s
2296MB", "11.6s
1720MB", "11.5s
1720MB
", "8.99s
1720MB
", "7.11s
4600MB
" ], }, { x: [ 0, 0, 47.411, 46.7195, 46.5013, 41.3253, 38.0013, 33.6112, 32.8001, 27.7112, 24.9112, 22.4112, 21.1112, 15.6112, 15.1112, 13.1112, 12.4112, 11.9112, 11.6112, 8.9911, 7.1111 ], y: m2y, name: measurement_names[0] + ' (robin_hood::hash)', type: 'bar', orientation: 'h', yaxis: 'y2', marker: { color: colors[0], }, textposition: 'outside', text: [ "47.4s
4156MB", "46.7s
3989MB", "46.5s
3777MB", "41.3s
4161MB", "38.0s
3777MB", "33.6s
4161MB", "32.8s
4160MB", "27.7s
1233MB", "24.9s
1060MB
", "22.4s
4033MB", "21.1s
2297MB", "15.6s
1537MB", "15.1s
1181MB
", "13.1s
1720MB", "12.4s
3064MB", "11.9s
2296MB", "11.6s
1720MB", "11.5s
1720MB
", "8.99s
1720MB
", "7.11s
4600MB
" ], }, { x: [ 0, 0, 46.7195, 45.8197, 43.3253, 39.7176, 37.2546, 30.3592, 26.6751, 24.2579, 21.7569, 20.2528, 15.0232, 13.9146, 13.091, 11.9234, 10.9833, 10.4468, 8.26594, 5.9112 ], y: m3y, name: measurement_names[0] + ' (Identity)', type: 'bar', orientation: 'h', yaxis: 'y4', marker: { color: colors[0], }, textposition: 'outside', text: [ "timeout", "timeout", "46.7s
3777MB", "45.8s
3989MB", "43.3s
4156MB", "39.7s
4161MB", "37.3s
3776MB", "30.4s
4160MB", "26.7s
1233MB", "24.3s
1060MB
", "21.8s
4033MB", "20.3s
2297MB", "15.0s
1536MB", "13.9s
1181MB
", "13.1s
1721MB", "11.9s
3064MB", "11.0s
1720MB
", "10.4s
2296MB", "8.27s
1720MB
", "5.91s
4600MB
" ], }, { x: [ 0, 0, 46.2752, 45.6408, 44.4415, 40.7703, 40.6562, 31.647, 27.6576, 24.8331, 22.714, 21.0315, 16.516, 15.5407, 12.0583, 11.9637, 11.4148, 10.9306, 9.04966, 7.0222 ], y: m4y, name: measurement_names[0] + ' (folly::hasher)', type: 'bar', orientation: 'h', yaxis: 'y5', marker: { color: colors[0], }, textposition: 'outside', text: [ "timeout", "timeout", "46.3s
3989MB", "45.6s
3777MB", "44.4s
4156MB", "40.8s
4160MB", "40.7s
3777MB", "31.6s
4161MB", "27.7s
1233MB", "24.8s
1060MB
", "22.7s
4034MB", "21.0s
2296MB", "16.5s
1181MB
", "15.5s
1537MB
", "12.1s
1720MB
", "12.0s
1720MB", "11.4s
2297MB", "10.9s
3064MB", "9.05s
1720MB
", "7.02s
4600MB
" ], }, ]; var layout = { // title: { text: 'InsertManyInt'}, grid: { ygap: 0.1, subplots: [ ['xy'], ['xy2'], ['xy3'], ['xy4'], ['xy5'], ] }, barmode: 'stack', yaxis: { title: 'absl::Hash', automargin: true, }, yaxis2: { title: 'robin_hood::hash', automargin: true, }, yaxis3: { title: 'FNV1a', automargin: true, }, yaxis4: { title: 'Identity', automargin: true, }, yaxis5: { title: 'folly::hasher', automargin: true, }, xaxis: { automargin: true, }, legend: { traceorder: 'normal' }, margin: { pad: 0, l:0, r:0, t:0, b:0, }, showlegend:false, }; Plotly.newPlot('id_ebc96fe0', data, layout); ``` -------------------------------- ### Insert Many Integers Benchmark Data (FNV1a) Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/html/bench_results/martinus_mod/InsertManyInt.html This data represents the benchmark results for inserting 100 million integers using FNV1a hashing. It includes execution time and memory usage for various hash map implementations. ```javascript var m2y = [ "eastl::hash_map", "std::unordered_map", "boost::unordered_map 1_58", "phmap::
parallel_node_hash_map", "boost::multi_index::
hashed_unique", "absl::node_hash_map", "phmap::node_hash_map", "spp::sparse_hash_map", "tsl::sparse_map", "folly::F14NodeMap", "robin_hood::
unordered_node_map", "folly::F14ValueMap", "phmap::
parallel_flat_hash_map
", "absl::flat_hash_map", "tsl::hopscotch_map", "emilib1::HashMap", "phmap::flat_hash_map", "ska::bytell_hash_map", "robin_hood::
unordered_flat_map
", "tsl::robin_map" ]; var data = [ // ... previous data ... { x: [47.4464, 46.6774, 46.5407, 41.3329, 38.0029, 33.5645, 32.8472, 27.6975, 24.856, 22.4334, 21.0759, 15.6409, 15.0877, 13.0797, 12.4225, 11.8954, 11.5608, 11.4623, 8.98865, 7.1118], y: m2y, name: measurement_names[0] + ' (FNV1a)', type: 'bar', orientation: 'h', yaxis: 'y3' } ``` -------------------------------- ### Define Test Targets Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/CMakeLists.txt Defines individual test targets using the 'phmap_cc_test' macro. Each target specifies the source file and dependencies, primarily Google Test libraries. ```cmake phmap_cc_test(NAME container_memory SRCS "tests/container_memory_test.cc" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME hash_policy_testing SRCS "tests/hash_policy_testing_test.cc" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME node_hash_policy SRCS "tests/node_hash_policy_test.cc" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME raw_hash_set SRCS "tests/raw_hash_set_test.cc" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME raw_hash_set_allocator SRCS "tests/raw_hash_set_allocator_test.cc" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME flat_hash_set SRCS "tests/flat_hash_set_test.cc" COPTS "-DUNORDERED_SET_CXX17" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME flat_hash_map SRCS "tests/flat_hash_map_test.cc" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME node_hash_map SRCS "tests/node_hash_map_test.cc" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME node_hash_set SRCS "tests/node_hash_set_test.cc" COPTS "-DUNORDERED_SET_CXX17" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME parallel_flat_hash_map SRCS "tests/parallel_flat_hash_map_test.cc" COPTS "-DUNORDERED_MAP_CXX17" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME parallel_flat_hash_set SRCS "tests/parallel_flat_hash_set_test.cc" COPTS "-DUNORDERED_SET_CXX17" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME parallel_node_hash_map SRCS "tests/parallel_node_hash_map_test.cc" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME parallel_node_hash_set SRCS "tests/parallel_node_hash_set_test.cc" COPTS "-DUNORDERED_SET_CXX17" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME parallel_flat_hash_map_mutex SRCS "tests/parallel_flat_hash_map_mutex_test.cc" COPTS "-DUNORDERED_MAP_CXX17" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME dump_load SRCS "tests/dump_load_test.cc" COPTS "-DUNORDERED_MAP_CXX17" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME erase_if SRCS "tests/erase_if_test.cc" COPTS "-DUNORDERED_MAP_CXX17" DEPS ${PHMAP_GTEST_LIBS}) ``` ```cmake phmap_cc_test(NAME btree SRCS "tests/btree_test.cc" DEPS ${PHMAP_GTEST_LIBS}) ``` -------------------------------- ### Enable Non-Deterministic Iteration Order Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/README.md Define PHMAP_NON_DETERMINISTIC to 1 before including phmap.h to enable internal hash seed randomization, useful for preventing DoS attacks. ```c++ #define PHMAP_NON_DETERMINISTIC 1 #include "phmap.h" ``` -------------------------------- ### Y-Axis Runtime Settings Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/benchmark/charts-template.html Configures the y-axis for displaying runtime in seconds. Includes label width and a formatter to append 'sec.' to tick values. ```javascript yaxis_runtime_settings = { labelWidth: 60, tickFormatter: function(num, obj) { return num + ' sec.'; } }; ``` -------------------------------- ### Chart Series and Grid Settings Source: https://github.com/greg7mdp/parallel-hashmap/blob/master/benchmark/charts-template.html Defines settings for chart lines, points, and grid ticks. These are used to configure the visual appearance of the benchmark charts. ```javascript series_settings = { lines: { show: true, lineWidth: 2 }, points: { show: true, radius: 2 } }; grid_settings = { tickColor: '#ddd' }; ```