Electroneum
Loading...
Searching...
No Matches
tools::LoggingPerformanceTimer Class Reference

#include <perf_timer.h>

Inheritance diagram for tools::LoggingPerformanceTimer:
Collaboration diagram for tools::LoggingPerformanceTimer:

Public Member Functions

 LoggingPerformanceTimer (const std::string &s, const std::string &cat, uint64_t unit, el::Level l=el::Level::Info)
 ~LoggingPerformanceTimer ()
Public Member Functions inherited from tools::PerformanceTimer
 PerformanceTimer (bool paused=false)
 ~PerformanceTimer ()
void pause ()
void resume ()
void reset ()
uint64_t value () const
 operator uint64_t () const

Additional Inherited Members

Protected Attributes inherited from tools::PerformanceTimer
uint64_t ticks
bool started
bool paused

Detailed Description

Definition at line 65 of file perf_timer.h.

Constructor & Destructor Documentation

◆ LoggingPerformanceTimer()

tools::LoggingPerformanceTimer::LoggingPerformanceTimer ( const std::string & s,
const std::string & cat,
uint64_t unit,
el::Level l = el::Level::Info )

Definition at line 115 of file perf_timer.cpp.

115 : PerformanceTimer(), name(s), cat(cat), unit(unit), level(l)
116{
117 const bool log = ELPP->vRegistry()->allowed(level, cat.c_str());
118 if (!performance_timers)
119 {
120 if (log)
121 PERF_LOG_ALWAYS(level, cat.c_str(), "PERF ----------");
122 performance_timers = new std::vector<LoggingPerformanceTimer*>();
123 performance_timers->reserve(16); // how deep before realloc
124 }
125 else
126 {
127 LoggingPerformanceTimer *pt = performance_timers->back();
128 if (!pt->started && !pt->paused)
129 {
130 if (log)
131 {
132 size_t size = 0; for (const auto *tmp: *performance_timers) if (!tmp->paused) ++size;
133 PERF_LOG_ALWAYS(pt->level, cat.c_str(), "PERF " << std::string((size-1) * 2, ' ') << " " << pt->name);
134 }
135 pt->started = true;
136 }
137 }
138 performance_timers->push_back(this);
139}
LoggingPerformanceTimer(const std::string &s, const std::string &cat, uint64_t unit, el::Level l=el::Level::Info)
PerformanceTimer(bool paused=false)
#define ELPP
#define PERF_LOG_ALWAYS(level, cat, x)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~LoggingPerformanceTimer()

tools::LoggingPerformanceTimer::~LoggingPerformanceTimer ( )

Definition at line 147 of file perf_timer.cpp.

148{
149 pause();
150 performance_timers->pop_back();
151 const bool log = ELPP->vRegistry()->allowed(level, cat.c_str());
152 if (log)
153 {
154 char s[12];
155 snprintf(s, sizeof(s), "%8llu ", (unsigned long long)(ticks_to_ns(ticks) / (1000000000 / unit)));
156 size_t size = 0; for (const auto *tmp: *performance_timers) if (!tmp->paused || tmp==this) ++size;
157 PERF_LOG_ALWAYS(level, cat.c_str(), "PERF " << s << std::string(size * 2, ' ') << " " << name);
158 }
159 if (performance_timers->empty())
160 {
161 delete performance_timers;
162 performance_timers = NULL;
163 }
164}
uint64_t ticks_to_ns(uint64_t ticks)
Here is the call graph for this function:

The documentation for this class was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/common/perf_timer.h
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/src/common/perf_timer.cpp