Improve Profiler documentation

This commit is contained in:
ZavGaro 2024-06-25 16:15:11 +03:00
parent e41e2c43e8
commit 4dc3fd2fcc

@ -31,10 +31,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/** \defgroup Profiling Profiling tools /** \defgroup Profiling Profiling tools
\brief In-engine tools to profile CPU time or everything else that is recorded \brief Embedded tools to profile CPU time or anything else that is recorded
in by special functions. by certain functions.
Usage example with global profiler (#g_profiler), that is available in any file An example with global profiler (#g_profiler), that is available in any file
with profiler.h included: with profiler.h included:
\code{.c++} \code{.c++}
void functionToProfie(int count) { void functionToProfie(int count) {
@ -193,18 +193,14 @@ class Profiler
/** \brief Global profiler. User can view its data via in-game profiler menu, /** \brief Global profiler. User can view its data via in-game profiler menu,
graph or "/profiler" command. graph or "/profiler" command.
It collects data for Profiling cycles are managed in Game class:
- itself, in Game::updateProfilers(); result is given in text form by print()
(user can view it via in-game profiler menu or "/profiler" command);
- profiler graph, in Game::updateProfilerGraphs(); result is displayed by - cycle for profiler menu (GameUI::updateProfiler()) is managed in
ProfilerGraph. Game::updateProfilers() and lasts for \c profiler_print_interval seconds (user
setting) or for 3 seconds if setting is setted to 0;
Cycle for profiler graph data lasts for one frame. Cycle for all other data lasts - cycle for ProfilerGraph is managed in Game::updateProfilerGraphs() and lasts
for \c profiler_print_interval seconds (user setting) or for 3 seconds if setting for one frame;
is setted to 0, and managed in Game::updateProfilers().
All corresponding data is cleared at cycle end.
*/ */
extern Profiler* g_profiler; extern Profiler* g_profiler;
@ -231,19 +227,21 @@ enum ScopeProfilerType : u8
class ScopeProfiler class ScopeProfiler
{ {
public: public:
/// \brief Begins record untill scope end. Result will be added to \p name profiling /** \brief Begins measurement untill scope end.Result will be recorded to
/// entry in \p profiler (profiling entries are created/deleted automatically). \p name
profiling entry in \p profiler (profiling entries are created/deleted automatically).
*/
ScopeProfiler(Profiler *profiler, const std::string &name, ScopeProfiler(Profiler *profiler, const std::string &name,
ScopeProfilerType type = SPT_ADD, ScopeProfilerType type = SPT_ADD,
TimePrecision precision = PRECISION_MILLI); TimePrecision precision = PRECISION_MILLI);
/// Ends record and logs result in profiler. /// Ends measurement and record result in profiler.
~ScopeProfiler(); ~ScopeProfiler();
private: private:
Profiler *m_profiler = nullptr; Profiler *m_profiler = nullptr; /// Profiler to record in
std::string m_name; std::string m_name; /// Name of profiler entry to record in
u64 m_time1; /// Record start time u64 m_time1; /// Record start time
ScopeProfilerType m_type; ScopeProfilerType m_type;
TimePrecision m_precision; TimePrecision m_precision;
}; };