Add history to intervals
parent
a196a2aa7d
commit
001b6ae46a
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <blt/std/queue.h>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <blt/std/logging.h>
|
||||
|
||||
|
@ -29,6 +30,7 @@ namespace blt::profiling {
|
|||
|
||||
struct Profile {
|
||||
std::unordered_map<std::string, CaptureInterval> intervals;
|
||||
std::unordered_map<std::string, std::vector<CaptureInterval>> historicalIntervals;
|
||||
blt::flat_queue<CapturePoint> 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<CaptureInterval> 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);
|
||||
|
|
|
@ -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<CaptureInterval> getAllIntervals(const std::string& profileName, const std::string& intervalName) {
|
||||
return profiles[profileName].historicalIntervals[intervalName];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue