Typedefs for maps

v1
Brett 2022-12-27 00:51:37 -05:00
parent c0955f0762
commit 7cf07bb5c0
3 changed files with 39 additions and 6 deletions

View File

@ -18,6 +18,15 @@ else()
set(PROFILING_FILES "")
endif()
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap/CMakeLists.txt)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap/)
set(PHMAP_ENABLED ON)
endif()
configure_file(include/blt/config.h.in blt/config.h @ONLY)
# include the config file
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(include/)
message("Standard Files ${STD_FILES}")
@ -27,3 +36,4 @@ message("Current Source: ${CMAKE_CURRENT_SOURCE_DIR}")
add_library(BLT ${STD_FILES} ${PROFILING_FILES})
target_include_directories(BLT PUBLIC include/)
target_link_libraries(BLT phmap)

12
include/blt/config.h.in Normal file
View File

@ -0,0 +1,12 @@
/*
* Created by Brett on 27/12/22.
* Licensed under GNU General Public License V3.0
* See LICENSE file for license detail
*/
#ifndef CMAKE_CONFIG
#cmakedefine PHMAP_ENABLED
#define CMAKE_CONFIG
#endif

View File

@ -9,7 +9,13 @@
#include <string>
#include <string_view>
#include <blt/config.h>
#ifdef PHMAP_ENABLED
#include <parallel_hashmap/phmap.h>
#else
#include <unordered_map>
#endif
namespace BLT {
@ -21,15 +27,20 @@ namespace BLT {
CapturePoint start;
CapturePoint end;
};
#ifdef PHMAP_ENABLED
typedef phmap::parallel_flat_hash_map<std::string_view, CaptureInterval> INTERVAL_MAP;
typedef phmap::parallel_flat_hash_map<std::string_view, CapturePoint> POINT_MAP;
#else
typedef std::unordered_map<std::string_view, CaptureInterval> INTERVAL_MAP;
typedef std::unordered_map<std::string_view, CapturePoint> POINT_MAP;
#endif
class Profiler {
private:
std::map<std::string_view, CaptureInterval>* intervals;
std::map<std::string_view, CapturePoint>* points;
INTERVAL_MAP intervals;
POINT_MAP points;
public:
Profiler(std::map<std::string_view, CaptureInterval>* test) {
intervals = test;
}
Profiler();
};
}