Electroneum
Loading...
Searching...
No Matches
epee::ado_db_helper::profiler_manager Class Reference

#include <ado_db_helper.h>

Public Types

typedef std::map< std::string, profile_entrysqls_map

Public Member Functions

 profiler_manager ()
bool flush_log (const std::string &path)
bool push_entry (const std::string sql, DWORD time)
bool get_entry_avarege (const std::string sql, DWORD &time)

Static Public Member Functions

static bool sort_by_timing (const sqls_map::iterator &a, const sqls_map::iterator &b)

Detailed Description

Definition at line 82 of file ado_db_helper.h.

Member Typedef Documentation

◆ sqls_map

Definition at line 85 of file ado_db_helper.h.

Constructor & Destructor Documentation

◆ profiler_manager()

epee::ado_db_helper::profiler_manager::profiler_manager ( )
inline

Definition at line 86 of file ado_db_helper.h.

86{}

Member Function Documentation

◆ flush_log()

bool epee::ado_db_helper::profiler_manager::flush_log ( const std::string & path)
inline

Definition at line 93 of file ado_db_helper.h.

94 {
95 CRITICAL_REGION_BEGIN(m_sqls_lock);
96 std::stringstream strm;
97 strm << "SQL PROFILE:\r\nStatements: " << m_sqls.size() << "\r\n";
98 std::list<sqls_map::iterator> m_sorted_by_time_sqls;
99 for(std::map<std::string, profile_entry>::iterator it = m_sqls.begin();it!=m_sqls.end();it++)
100 m_sorted_by_time_sqls.push_back(it);
101
102 m_sorted_by_time_sqls.sort(sort_by_timing);
103
104 for(std::list<sqls_map::iterator>::iterator it = m_sorted_by_time_sqls.begin();it!=m_sorted_by_time_sqls.end();it++)
105 {
106 strm << "---------------------------------------------------------------------------------------------------------\r\nSQL: " << (*it)->first << "\r\n";
107 strm << "\tavrg: " << (*it)->second.m_avrg.get_avg() << "\r\n\tmax: " << (*it)->second.m_max_time << "\r\n\tmin: " << (*it)->second.m_min_time << "\r\n\tcount: " << (*it)->second.m_call_count << "\r\n";
108 }
109
110 return file_io_utils::save_string_to_file(path.c_str(), strm.str());
112 }
static bool sort_by_timing(const sqls_map::iterator &a, const sqls_map::iterator &b)
bool save_string_to_file(const std::string &path_to_file, const std::string &str)
#define CRITICAL_REGION_END()
Definition syncobj.h:233
#define CRITICAL_REGION_BEGIN(x)
Definition syncobj.h:229
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_entry_avarege()

bool epee::ado_db_helper::profiler_manager::get_entry_avarege ( const std::string sql,
DWORD & time )
inline

Definition at line 126 of file ado_db_helper.h.

127 {
128 CRITICAL_REGION_BEGIN(m_sqls_lock);
129 sqls_map::iterator it = m_sqls.find(sql);
130 if(it==m_sqls.end())
131 return false;
132
133 time = static_cast<DWORD>(it->second.m_avrg.get_avg());
135 return true;
136 }
time_t time

◆ push_entry()

bool epee::ado_db_helper::profiler_manager::push_entry ( const std::string sql,
DWORD time )
inline

Definition at line 114 of file ado_db_helper.h.

115 {
116 CRITICAL_REGION_BEGIN(m_sqls_lock);
117 profile_entry& entry_ref = m_sqls[sql];
118 entry_ref.m_avrg.push(time);
119 entry_ref.m_call_count++;
120 if(time > entry_ref.m_max_time) entry_ref.m_max_time = time;
121 if(time < entry_ref.m_min_time || entry_ref.m_min_time == 0) entry_ref.m_min_time = time;
123 return true;
124 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sort_by_timing()

bool epee::ado_db_helper::profiler_manager::sort_by_timing ( const sqls_map::iterator & a,
const sqls_map::iterator & b )
inlinestatic

Definition at line 88 of file ado_db_helper.h.

89 {
90 return a->second.m_avrg.get_avg() > b->second.m_avrg.get_avg();
91 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1124
Here is the caller graph for this function:

The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/contrib/epee/include/ado_db_helper.h