24 #define TRACY_ENABLE 1
25 #include <tracy/Tracy.hpp>
51 explicit Profiler(
const std::string& name,
bool doReport =
true);
57 void start(
const std::string& funcName);
59 void stop(
const std::string& funcName);
62 template<
class Stream>
void report(Stream& os)
const;
88 friend std::ostream&
operator<<(std::ostream& os,
const Profile& p);
131 #define PROFILE(label) ZoneNamedN(_prof, #label, true)
134 #define PROFILE(label) utl::prof _prof(label)
137 #if PROFILE_LEVEL >= 1
138 #define PROFILE1(label) PROFILE(label)
141 #define PROFILE1(label)
144 #if PROFILE_LEVEL >= 2
145 #define PROFILE2(label) PROFILE(label)
148 #define PROFILE2(label)
151 #if PROFILE_LEVEL >= 3
152 #define PROFILE3(label) PROFILE(label)
155 #define PROFILE3(label)
158 #if PROFILE_LEVEL >= 4
159 #define PROFILE4(label) PROFILE(label)
162 #define PROFILE4(label)
Simple class for profiling of computational tasks.
Definition: Profiler.h:42
void stop(const std::string &funcName)
Stops profiling of task funcName and decrements nRunners.
Definition: Profiler.C:110
~Profiler()
The destructor prints the profiling report to the console, if autoReport is true.
Definition: Profiler.C:49
int nRunners
Number of tasks currently running.
Definition: Profiler.h:107
ProfileMap myTimers
The task profiles with names.
Definition: Profiler.h:95
bool autoReport
Whether or not to report results on program exit.
Definition: Profiler.h:91
void clear()
Clears the profiler.
Definition: Profiler.h:64
static bool indentReport
If true, indicate task level by indent.
Definition: Profiler.h:66
std::map< std::string, Profile > ProfileMap
Map of profilers.
Definition: Profiler.h:93
std::string myName
Name of this profiler.
Definition: Profiler.h:90
double allCPU
Accumulated CPU time from all "main" tasks.
Definition: Profiler.h:98
friend std::ostream & operator<<(std::ostream &os, const Profile &p)
Global stream operator printing a Profile instance.
Definition: Profiler.C:144
double allWall
Accumulated wall clock time of all "main" tasks.
Definition: Profiler.h:99
Profiler(const std::string &name, bool doReport=true)
The constructor initializes the profiler object.
Definition: Profiler.C:31
void start(const std::string &funcName)
Starts profiling of task funcName and increments nRunners.
Definition: Profiler.C:86
std::vector< ProfileMap > myMTimers
Task profiles with names and thread iD.
Definition: Profiler.h:96
void report(Stream &os) const
Prints a profiling report for all tasks that have been measured.
Definition: Profiler.C:175
Convenience class to profile the local scope.
Definition: Profiler.h:117
prof(const char *tag)
The constructor starts the profiling of the named task.
Definition: Profiler.h:121
const char * name
Name tag on the local scope to profile.
Definition: Profiler.h:118
~prof()
The destructor stops the profiling.
Definition: Profiler.h:124
General utility classes and functions.
Definition: SIMoptions.h:22
Profiler * profiler
Pointer to the one and only profiler object.
Definition: Profiler.C:27
Stores profiling data for one computational task.
Definition: Profiler.h:71
double totalWall
Total wall clock time consumed by this task so far.
Definition: Profiler.h:75
clock_t startCPU
The last starting CPU time of this task.
Definition: Profiler.h:72
bool running
Flag indicating if this task is currently running.
Definition: Profiler.h:77
double startWall
The last starting wall clock time of this task.
Definition: Profiler.h:73
double totalCPU
Total CPU time consumed by this task so far.
Definition: Profiler.h:74
size_t nCalls
Number of invokations of this task.
Definition: Profiler.h:76
Profile()
The constructor initializes the total times to zero.
Definition: Profiler.h:81
int level
Task level (used for indent in profiling report)
Definition: Profiler.h:78
bool haveTime() const
Checks if this profile item have any timing to report.
Definition: Profiler.h:84