79 void do_enter(
const std::string_view& func_name);
80 double do_leave(
const std::string_view& func_name);
93 const bool keep_whole_history =
false);
109 void getStats(std::map<std::string, TCallStats>& out_stats)
const;
112 void dumpAllStats(
const size_t column_width = 80)
const;
133 const std::string_view& event_name,
const double value,
134 const bool is_time =
false);
140 inline void enter(
const std::string_view& func_name)
146 inline double leave(
const std::string_view& func_name)
192 const CTimeLogger& logger,
const std::string_view& section_name);
const std::string & getName() const
std::chrono::time_point< Clock > time_point
A safe way to call enter() and leave() of a mrpt::system::CTimeLogger upon construction and destructi...
void clear(bool deep_clear=false)
Resets all stats.
mrpt::system::CTimeLogger & m_tm
void dumpAllStats(const size_t column_width=80) const
Dump all stats through the COutputLogger interface.
A high-performance stopwatch, with typical resolution of nanoseconds.
mrpt::system::CTimeLogger & global_profiler_getref() noexcept
double getLastTime(const std::string &name) const
Return the last execution time of the given "section", or 0 if it hasn't ever been called "enter" wit...
void getStats(std::map< std::string, TCallStats > &out_stats) const
Returns all the current stats as a map: section_name => stats.
void registerUserMeasure(const std::string_view &event_name, const double value, const bool is_time=false)
void stop()
for correct use, see docs for CTimeLoggerEntry
std::string getStatsAsText(const size_t column_width=80) const
Dump all stats to a multi-line text string.
void setName(const std::string &name)
std::stack< double, std::vector< double > > open_calls
void global_profiler_enter(const char *func_name) noexcept
void saveToMFile(const std::string &m_file) const
Dump all stats to a Matlab/Octave (.m) file.
std::optional< std::deque< double > > whole_history
Versatile class for consistent logging and management of output messages.
bool m_keep_whole_history
const std::string m_section_name
static constexpr unsigned int HASH_ALLOWED_COLLISIONS
double do_leave(const std::string_view &func_name)
CTimeLogger(bool enabled=true, const std::string &name="", const bool keep_whole_history=false)
ts_hash_map()=default
< Default constructor */
A helper class to save CSV stats upon self destruction, for example, at the end of a program run...
mrpt::Clock::time_point m_entry
GLsizei const GLchar ** string
double getMeanTime(const std::string &name) const
Return the mean execution time of the given "section", or 0 if it hasn't ever been called "enter" wit...
void enableKeepWholeHistory(bool enable=true)
void enable(bool enabled=true)
void global_profiler_leave(const char *func_name) noexcept
mrpt::containers::ts_hash_map< std::string, TCallData, HASH_SIZE_IN_BYTES, HASH_ALLOWED_COLLISIONS > TDataMap
A versatile "profiler" that logs the time spent within each pair of calls to enter(X)-leave(X), among other stats.
void saveToCSVFile(const std::string &csv_file) const
Dump all stats to a Comma Separated Values (CSV) file.
void deep_clear(CONTAINER &c)
Deep clear for a std vector container.
Data of each call section: # of calls, minimum, maximum, average and overall execution time (in secon...
GLuint const GLchar * name
CTimeLoggerSaveAtDtor(mrpt::system::CTimeLogger &tm)
bool isEnabledKeepWholeHistory() const
GLsizei const GLfloat * value
void do_enter(const std::string_view &func_name)
static constexpr unsigned int HASH_SIZE_IN_BYTES
void enter(const std::string_view &func_name)
Start of a named section.
CTimeLoggerEntry(const CTimeLogger &logger, const std::string_view §ion_name)
double leave(const std::string_view &func_name)
End of a named section.
~CTimeLogger() override
Destructor.
CTimeLogger & operator=(const CTimeLogger &o)=default