diff --git a/CMakeLists.txt b/CMakeLists.txt index 69b743f..c0d2c48 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,38 +88,38 @@ endif() message("BLT ${CMAKE_PROJECT_VERSION} Successfully included!") -if(${BUILD_TESTS}) - project(BLT_TESTS) - - file(GLOB_RECURSE TESTS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/*.cpp") - - add_executable(BLT_TESTS ${TESTS_FILES}) - - target_link_libraries(BLT_TESTS PUBLIC BLT) - - if(MSVC) - #target_compile_options(BLT_TESTS PRIVATE /W4) - if(${CMAKE_BUILD_TYPE} MATCHES Debug) - target_link_options(BLT_TESTS PRIVATE /DEBUG) - endif() - else() - target_compile_options(BLT_TESTS PRIVATE -Wall -Wextra -Wpedantic) - endif() - - if (${ENABLE_ADDRSAN} MATCHES ON) - target_compile_options(BLT_TESTS PRIVATE -fsanitize=address) - target_link_options(BLT_TESTS PRIVATE -fsanitize=address) - endif () - - if (${ENABLE_UBSAN} MATCHES ON) - target_compile_options(BLT_TESTS PRIVATE -fsanitize=undefined) - target_link_options(BLT_TESTS PRIVATE -fsanitize=undefined) - endif () - - if (${ENABLE_TSAN} MATCHES ON) - target_compile_options(BLT_TESTS PRIVATE -fsanitize=thread) - target_link_options(BLT_TESTS PRIVATE -fsanitize=thread) - endif () - - message("BLT tests included!") -endif() +#if(${BUILD_TESTS}) +# project(BLT_TESTS) +# +# file(GLOB_RECURSE TESTS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/*.cpp") +# +# add_executable(BLT_TESTS ${TESTS_FILES}) +# +# target_link_libraries(BLT_TESTS PUBLIC BLT) +# +# if(MSVC) +# #target_compile_options(BLT_TESTS PRIVATE /W4) +# if(${CMAKE_BUILD_TYPE} MATCHES Debug) +# target_link_options(BLT_TESTS PRIVATE /DEBUG) +# endif() +# else() +# target_compile_options(BLT_TESTS PRIVATE -Wall -Wextra -Wpedantic) +# endif() +# +# if (${ENABLE_ADDRSAN} MATCHES ON) +# target_compile_options(BLT_TESTS PRIVATE -fsanitize=address) +# target_link_options(BLT_TESTS PRIVATE -fsanitize=address) +# endif () +# +# if (${ENABLE_UBSAN} MATCHES ON) +# target_compile_options(BLT_TESTS PRIVATE -fsanitize=undefined) +# target_link_options(BLT_TESTS PRIVATE -fsanitize=undefined) +# endif () +# +# if (${ENABLE_TSAN} MATCHES ON) +# target_compile_options(BLT_TESTS PRIVATE -fsanitize=thread) +# target_link_options(BLT_TESTS PRIVATE -fsanitize=thread) +# endif () +# +# message("BLT tests included!") +#endif() diff --git a/include/blt/std/filesystem.h b/include/blt/std/filesystem.h index 2c1d049..b864e2c 100755 --- a/include/blt/std/filesystem.h +++ b/include/blt/std/filesystem.h @@ -13,6 +13,13 @@ namespace blt::fs { + class path + { + private: + std::vector paths; + public: + + }; /** * A simple interface which provides a way of reading the next block of data from a resource. @@ -102,7 +109,8 @@ namespace blt::fs int read(char* buffer, size_t bytes) override; - size_t gcount() final { + size_t gcount() final + { return m_stream.gcount(); } diff --git a/include/blt/std/hashmap.h b/include/blt/std/hashmap.h index 8caf46b..6f35191 100755 --- a/include/blt/std/hashmap.h +++ b/include/blt/std/hashmap.h @@ -7,6 +7,20 @@ #ifndef BLT_HASH_MAP_H #define BLT_HASH_MAP_H +namespace blt +{ + +// template, typename Eq = std::equal_to> +// class hashmap +// { +// private: +// +// public: +// +// }; + +} + #ifndef HASHMAP #if defined __has_include && __has_include() diff --git a/include/blt/std/time.h b/include/blt/std/time.h index 292a0ca..50d6759 100755 --- a/include/blt/std/time.h +++ b/include/blt/std/time.h @@ -11,39 +11,79 @@ #ifndef BLT_TIME_H #define BLT_TIME_H -namespace blt::system { - static inline std::string ensureHasDigits(int current, int digits) { +namespace blt::system +{ + static inline std::string ensureHasDigits(int current, int digits) + { std::string asString = std::to_string(current); auto length = digits - asString.length(); if (length <= 0) return asString; std::string zeros; zeros.reserve(length); - for (unsigned int i = 0; i < length; i++){ + for (unsigned int i = 0; i < length; i++) + { zeros += '0'; } return zeros + asString; } - static inline auto getCurrentTimeNanoseconds() { + static inline auto getCurrentTimeNanoseconds() + { return std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); } - static inline auto nanoTime() { + static inline auto nanoTime() + { return getCurrentTimeNanoseconds(); } - static inline auto getCurrentTimeMilliseconds(){ + static inline auto getCurrentTimeMilliseconds() + { return std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); } + static inline auto getCPUThreadTime() + { +#ifdef unix + timespec time{}; + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &time); + return time.tv_nsec; +#else + return std::clock(); +#endif + } + + static inline auto getCPUTime() + { +#ifdef unix + timespec time{}; + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time); + return time.tv_nsec; +#else + return std::clock(); +#endif + } + + static inline auto getCPUTimerResolution() + { +#ifdef unix + timespec res{}; + clock_getres(CLOCK_PROCESS_CPUTIME_ID, &res); + return res.tv_nsec; +#else + return CLOCKS_PER_SECOND; +#endif + } + /** * Standard time string is formatted as follows: * Year-Month-Date Hour:Min:Second * If you do not want a space in the string use getTimeStringFS(); (Time String for easy filesystem) * @return the BLT standard string of time.now */ - static inline std::string getTimeString() { + static inline std::string getTimeString() + { auto t = std::time(nullptr); auto now = std::localtime(&t); std::stringstream timeString; @@ -66,7 +106,8 @@ namespace blt::system { * Hour:Min:Second * @return the BLT standard logging string of time.now */ - static inline std::string getTimeStringLog() { + static inline std::string getTimeStringLog() + { auto t = std::time(nullptr); auto now = std::localtime(&t); std::string timeString = "["; @@ -82,7 +123,8 @@ namespace blt::system { /** * @return the BLT standard string of time.now (See getTimeString()) that is filesystem friendly (FAT compatible). */ - static inline std::string getTimeStringFS() { + static inline std::string getTimeStringFS() + { auto t = std::time(nullptr); auto now = std::localtime(&t); std::stringstream timeString; diff --git a/libraries/parallel-hashmap b/libraries/parallel-hashmap index 77cab81..93201da 160000 --- a/libraries/parallel-hashmap +++ b/libraries/parallel-hashmap @@ -1 +1 @@ -Subproject commit 77cab8192a879e5d27188f97e8f2080dd7e36ca8 +Subproject commit 93201da2ba5a6aba0a6e57ada64973555629b3e3