MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
shcore::profiling Namespace Reference

This namespace provides the functions required to perform profiling of specific sections of code. More...

Functions

void activate (bool trace_total)
 
void deactivate (bool trace_total)
 
void print_stats ()
 
void reset ()
 
void stage_begin (const std::string &id)
 
void stage_end (const std::string &id)
 

Variables

shcore::utils::Global_profilerg_active_profiler = nullptr
 

Detailed Description

This namespace provides the functions required to perform profiling of specific sections of code.

TO ACTIVATE THE PROFILER

Call the following functions to activate/deactivate it as needed:

  • mysqlshdk::profiling::activate();
  • mysqlshdk::profiling::deactivate();

Or do as follows to ensure it is active within a specific context:

mysqlshdk::profiling::activate(); auto finally = shcore::on_leave_scope([]() { mysqlshdk::profiling::deactivate(); });

TO ADD A MEASURING POINT WITHIN A THREAD

Call the following functions to measure the time spent between them:

  • mysqlshdk::profiling::stage_begin("<MEASURE ID>");
  • mysqlshdk::profiling::stage_end("<MEASURE ID>");

"<MEASURE ID>": Text to identify the context being measured.

Make sure the measure ID passed to both functions is the same. It will record a the number of milliseconds spend between both calls for each time the code is hit while the profiling is active.

To measure the time within a specific scope you can also use:

mysqlshdk::profiling::stage_begin("<MEASURE ID>"); shcore::on_leave_scope end_stage( []() { mysqlshdk::profiling::stage_end("<MEASURE ID>"); });

You can add as many measure points as needed.

Function Documentation

◆ activate()

void shcore::profiling::activate ( bool  trace_total)

◆ deactivate()

void shcore::profiling::deactivate ( bool  trace_total)

◆ print_stats()

void shcore::profiling::print_stats ( )
inline

◆ reset()

void shcore::profiling::reset ( )
inline

◆ stage_begin()

void shcore::profiling::stage_begin ( const std::string &  id)
inline

◆ stage_end()

void shcore::profiling::stage_end ( const std::string &  id)
inline

Variable Documentation

◆ g_active_profiler

shcore::utils::Global_profiler * shcore::profiling::g_active_profiler = nullptr