Many, many more comments

This commit is contained in:
2024-12-04 17:15:04 +01:00
parent 8696517336
commit 03854339ca
100 changed files with 1702 additions and 49 deletions
+11
View File
@@ -5,19 +5,30 @@
#include <map>
#include <string>
// structure to measure a timing (stores begin and endpoint and the corresponding timespan)
struct TimerEvent {
std::chrono::time_point<std::chrono::high_resolution_clock> start;
std::chrono::time_point<std::chrono::high_resolution_clock> stop;
std::chrono::duration<double, std::nano> total_timespan;
};
// class to time between a start and endpoint if the code has been compiled with
// USE_TIMER = true, otherwise does nothing
class SimulationTimer {
public:
// if first invocation of eventStartPoint with a specific event_name, adds a
// TimerEvent at the time it was called; otherwise sets the value to
// the time it has been invoked
static void eventStartPoint(std::string event_name);
// sets the endpoint in the TimerEvent struct to the time the function was called
// the event_name has to match with an eventStartPoint invocation (not checked)
// calculates the timedifference
static void eventStopPoint(std::string event_name);
// print a formatted string containing all event_names and their respective timing to stdout
static void printDurations();
private:
// map to store all event_names with their TimerEvent structs
static std::map<std::string, TimerEvent> timed_events_;
};