diff --git a/include/blt/profiling/profiler.h b/include/blt/profiling/profiler.h index ff47163..b460cc4 100644 --- a/include/blt/profiling/profiler.h +++ b/include/blt/profiling/profiler.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -29,6 +30,7 @@ namespace blt::profiling { struct Profile { std::unordered_map intervals; + std::unordered_map> historicalIntervals; blt::flat_queue points; }; @@ -38,6 +40,7 @@ namespace blt::profiling { void point(const std::string& profileName, const std::string& pointName); CaptureInterval getInterval(const std::string& profileName, const std::string& intervalName); + std::vector getAllIntervals(const std::string& profileName, const std::string& intervalName); Profile getProfile(const std::string& profileName); void printProfile(const std::string& profileName, blt::logging::LOG_LEVEL loggingLevel = logging::NONE); diff --git a/src/blt/profiling/profiler.cpp b/src/blt/profiling/profiler.cpp index a9461c3..55bf13d 100644 --- a/src/blt/profiling/profiler.cpp +++ b/src/blt/profiling/profiler.cpp @@ -28,6 +28,7 @@ namespace blt::profiling { void endInterval(const std::string& profileName, const std::string& intervalName) { std::scoped_lock lock(profileLock); profiles[profileName].intervals[intervalName].end = system::getCurrentTimeNanoseconds(); + profiles[profileName].historicalIntervals[intervalName].push_back(profiles[profileName].intervals[intervalName]); } void point(const std::string& profileName, const std::string& pointName) { @@ -125,9 +126,14 @@ namespace blt::profiling { void discardIntervals(const std::string& profileName) { profiles[profileName].intervals = {}; + profiles[profileName].historicalIntervals = {}; } void discardPoints(const std::string& profileName) { profiles[profileName].points = {}; } + + std::vector getAllIntervals(const std::string& profileName, const std::string& intervalName) { + return profiles[profileName].historicalIntervals[intervalName]; + } } \ No newline at end of file