79 void do_enter(
const std::string_view& func_name) noexcept;
80 double do_leave(
const std::string_view& func_name) noexcept;
92 bool enabled =
true,
const std::string& 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) noexcept;
140 inline void enter(
const std::string_view& func_name) noexcept
146 inline double leave(
const std::string_view& func_name) noexcept
192 const CTimeLogger& logger,
const std::string_view& section_name);
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.
void registerUserMeasure(const std::string_view &event_name, const double value, const bool is_time=false) noexcept
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 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.
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
void setName(const std::string &name) noexcept
double do_leave(const std::string_view &func_name) noexcept
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
void do_enter(const std::string_view &func_name) noexcept
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 enter(const std::string_view &func_name) noexcept
Start of a named section.
void global_profiler_leave(const char *func_name) noexcept
const std::string & getName() const 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...
double leave(const std::string_view &func_name) noexcept
End of a named section.
CTimeLoggerSaveAtDtor(mrpt::system::CTimeLogger &tm)
bool isEnabledKeepWholeHistory() const
static constexpr unsigned int HASH_SIZE_IN_BYTES
CTimeLoggerEntry(const CTimeLogger &logger, const std::string_view §ion_name)
~CTimeLogger() override
Destructor.
CTimeLogger & operator=(const CTimeLogger &o)=default