CEPS
24.01
Cardiac ElectroPhysiology Simulator
|
A Chronometer used to measure execution of blocks of code, plus some methods to get current memory usage of the process.
Several blocks of code can be tracked at the same time, by providing a name to the block that is measured. Usage:
The profiler log can be used to plot the memory usage. Here is an example of gnuplot script
Definition at line 70 of file CepsProfiler.hpp.
#include <CepsProfiler.hpp>
Public Member Functions | |
Profiler () | |
Constructor. More... | |
Profiler (const Profiler &)=delete | |
Copy constructor deleted, ideally, there should be one profiler per run. More... | |
Profiler & | operator= (const Profiler &)=delete |
Assignment operator deleted, ideally, there should be one profiler per run. More... | |
~Profiler () | |
Destructor. More... | |
void | start (CepsString lbl, CepsString dspl="") |
Creates or continue a labeled chronometer. More... | |
void | restart (CepsString lbl) |
Resets a labeled chronometer. More... | |
void | stop (CepsString lbl) |
Stops the measure of a labeled chronometer. More... | |
void | display (const CepsString &lbl, std::ostream &os) const |
Prints time spent by a specific chronometer. More... | |
void | display (const CepsString &lbl) const |
Prints time spent by a specific chronometer. More... | |
void | display (std::ostream &) const |
Prints time spent by all chronometers. More... | |
void | display () const |
Prints time spent by all chronometers. More... | |
void | logMemoryUsage (const CepsString &xtic) |
Writes a line with memory usage in profiling log, xtic is used to describe what the program is currently doing. More... | |
void | logMemoryUsageIf (CepsBool ifexpr, const CepsString &xtic) |
Writes a line with memory usage in profiling log if 'ifexpr' is true, xtic is used to describe what the program is currently doing. More... | |
size_t | localMemoryUsage () |
Returns an estimation of the memory taken by the current process (in kB) More... | |
size_t | globalMemoryUsage () |
Returns an estimation of the memory taken by all the MPI process (in kB) More... | |
Private Attributes | |
CepsMap< CepsString, CepsReal > | m_seconds |
Times. More... | |
CepsMap< CepsString, clock_t > | m_tmpTimes |
Temp evals for times. More... | |
CepsMap< CepsString, CepsString > | m_dsplStrs |
Text to display at the end of computation, typically. More... | |
CepsUInt | m_maxLen |
For nice output. More... | |
Profiler::Profiler | ( | ) |
Constructor.
Definition at line 41 of file CepsProfiler.cpp.
|
delete |
Copy constructor deleted, ideally, there should be one profiler per run.
Profiler::~Profiler | ( | ) |
Destructor.
Definition at line 46 of file CepsProfiler.cpp.
void Profiler::display | ( | ) | const |
Prints time spent by all chronometers.
Definition at line 98 of file CepsProfiler.cpp.
void Profiler::display | ( | const CepsString & | lbl | ) | const |
Prints time spent by a specific chronometer.
[in] | lbl | The name of the chronometer. |
Definition at line 91 of file CepsProfiler.cpp.
void Profiler::display | ( | const CepsString & | lbl, |
std::ostream & | os | ||
) | const |
Prints time spent by a specific chronometer.
[in] | lbl | The name of the chronometer. |
[in] | os | output stream |
Definition at line 82 of file CepsProfiler.cpp.
void Profiler::display | ( | std::ostream & | os | ) | const |
Prints time spent by all chronometers.
Definition at line 105 of file CepsProfiler.cpp.
size_t Profiler::globalMemoryUsage | ( | ) |
Returns an estimation of the memory taken by all the MPI process (in kB)
Definition at line 158 of file CepsProfiler.cpp.
size_t Profiler::localMemoryUsage | ( | ) |
Returns an estimation of the memory taken by the current process (in kB)
Definition at line 138 of file CepsProfiler.cpp.
void Profiler::logMemoryUsage | ( | const CepsString & | xtic | ) |
Writes a line with memory usage in profiling log, xtic is used to describe what the program is currently doing.
Definition at line 120 of file CepsProfiler.cpp.
void Profiler::logMemoryUsageIf | ( | CepsBool | ifexpr, |
const CepsString & | xtic | ||
) |
Writes a line with memory usage in profiling log if 'ifexpr' is true, xtic is used to describe what the program is currently doing.
Definition at line 130 of file CepsProfiler.cpp.
Assignment operator deleted, ideally, there should be one profiler per run.
void Profiler::restart | ( | CepsString | lbl | ) |
Resets a labeled chronometer.
[in] | lbl | The name of the chronometer. |
Definition at line 66 of file CepsProfiler.cpp.
void Profiler::start | ( | CepsString | lbl, |
CepsString | dspl = "" |
||
) |
Creates or continue a labeled chronometer.
[in] | lbl | The name of the chronometer. |
[in] | dspl | The CepsString that will be displayed when printing results. |
If the chronometer already exists, execution time will be added. (Start acts like continue)
Definition at line 51 of file CepsProfiler.cpp.
void Profiler::stop | ( | CepsString | lbl | ) |
Stops the measure of a labeled chronometer.
[in] | lbl | The name of the chronometer. |
Definition at line 74 of file CepsProfiler.cpp.
|
private |
Text to display at the end of computation, typically.
Definition at line 169 of file CepsProfiler.hpp.
|
private |
For nice output.
Definition at line 170 of file CepsProfiler.hpp.
|
private |
Times.
Definition at line 167 of file CepsProfiler.hpp.
|
private |
Temp evals for times.
Definition at line 168 of file CepsProfiler.hpp.