diff --git a/include/blt/profiling/profiler.h b/include/blt/profiling/profiler.h index c7d3896..7387a20 100644 --- a/include/blt/profiling/profiler.h +++ b/include/blt/profiling/profiler.h @@ -11,6 +11,7 @@ #include #include #include +#include #ifdef PHMAP_ENABLED #include @@ -30,7 +31,7 @@ namespace BLT { }; #ifdef PHMAP_ENABLED typedef phmap::parallel_flat_hash_map INTERVAL_MAP; - typedef phmap::parallel_flat_hash_map POINT_MAP; + typedef phmap::parallel_flat_hash_map> POINT_MAP; typedef phmap::parallel_flat_hash_map POINT_HISTORY_MAP; typedef phmap::parallel_flat_hash_map ORDER_MAP; #else @@ -43,8 +44,8 @@ namespace BLT { class Profiler { private: INTERVAL_MAP intervals{}; - POINT_MAP points{}; - POINT_MAP cyclicPoints{}; + std::queue points{}; + std::queue cyclicPoints{}; POINT_HISTORY_MAP cyclicPointsHistory{}; ORDER_MAP order{}; @@ -55,6 +56,11 @@ namespace BLT { void finishCycle(); void startInterval(const std::string_view& name); void endInterval(const std::string_view& name); + void profilerPoint(); + /** + * Uses a separate tracking device that will be reset when finishCycle(); is called. + */ + void profilerPointCyclic(); }; } diff --git a/include/blt/std/queues.h b/include/blt/std/queues.h index 988c443..c21d879 100644 --- a/include/blt/std/queues.h +++ b/include/blt/std/queues.h @@ -30,6 +30,11 @@ namespace BLT { int headIndex = 0; T* data = new T[size]; + /** + * Expands the internal array to the new size, copying over the data and shifting its minimal position to index 0 + * and deletes the old array from memory. + * @param newSize new size of the internal array + */ void expand(int newSize){ auto tempData = new T[newSize]; for (int i = 0; i < size - headIndex; i++) diff --git a/include/blt/std/random.h b/include/blt/std/random.h new file mode 100644 index 0000000..27900f7 --- /dev/null +++ b/include/blt/std/random.h @@ -0,0 +1,34 @@ +/* + * Created by Brett on 04/01/23. + * Licensed under GNU General Public License V3.0 + * See LICENSE file for license detail + */ + +#ifndef BLT_RANDOM_H +#define BLT_RANDOM_H + +#include + +namespace BLT { + /** + * Creates a container class for generating random number distributions + * @tparam T numeric type + * @tparam dist std::uniform_real_distribution or std::uniform_int_distribution + */ + template typename dist = std::uniform_real_distribution> + class Random { + private: + std::random_device rd; // obtain a random number from hardware + std::mt19937 gen; + dist* distribution = nullptr; + public: + explicit Random(T min = (T)0, T max = (T)1, long seed = 0): gen(std::mt19937(seed)){ + distribution = new dist(min, max); + } + T get(){ + return *distribution(gen); + } + }; +} + +#endif //BLT_RANDOM_H diff --git a/src/blt/profiling/profiler.cpp b/src/blt/profiling/profiler.cpp index b85c681..02a4a78 100644 --- a/src/blt/profiling/profiler.cpp +++ b/src/blt/profiling/profiler.cpp @@ -29,4 +29,13 @@ namespace BLT { intervals[name].end = {getCurrentTimeNanoseconds()}; order[lastOrder++] = name; } + + void Profiler::profilerPoint() { + + } + + void Profiler::profilerPointCyclic() { + + } + } \ No newline at end of file diff --git a/src/blt/std/random.cpp b/src/blt/std/random.cpp new file mode 100644 index 0000000..93d577c --- /dev/null +++ b/src/blt/std/random.cpp @@ -0,0 +1,6 @@ +/* + * Created by Brett on 04/01/23. + * Licensed under GNU General Public License V3.0 + * See LICENSE file for license detail + */ +#include \ No newline at end of file