34#undef ELECTRONEUM_DEFAULT_LOG_CATEGORY
35#define ELECTRONEUM_DEFAULT_LOG_CATEGORY "perf"
37#define PERF_LOG_ALWAYS(level, cat, x) \
38 el::base::Writer(level, __FILE__, __LINE__, ELPP_FUNC, el::base::DispatchAction::FileOnlyLog).construct(cat) << x
39#define PERF_LOG(level, cat, x) \
41 if (ELPP->vRegistry()->allowed(level, cat)) PERF_LOG_ALWAYS(level, cat, x); \
48#if defined(__x86_64__)
50 __asm__
volatile(
"rdtsc" :
"=a"(lo),
"=d"(hi));
66 if (
t1 -
t0 > 1*1000000000)
break;
71 return tpns256 ? tpns256 : 1;
81#if defined(__x86_64__)
82 return 256 * ticks / ticks_per_ns;
94static __thread std::vector<LoggingPerformanceTimer*> *performance_timers = NULL;
117 const bool log =
ELPP->vRegistry()->allowed(level, cat.c_str());
118 if (!performance_timers)
122 performance_timers =
new std::vector<LoggingPerformanceTimer*>();
123 performance_timers->reserve(16);
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);
138 performance_timers->push_back(
this);
150 performance_timers->pop_back();
151 const bool log =
ELPP->vRegistry()->allowed(level, cat.c_str());
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);
159 if (performance_timers->empty())
161 delete performance_timers;
162 performance_timers = NULL;
static const char * convertToString(Level level)
Converts level to associated const char*.
Level
Represents enumeration for severity level used to determine level of logging.
@ Warning
Useful when application has potentially harmful situtaions.
@ Info
Mainly useful to represent current progress of application.
@ Fatal
Severe error information that will presumably abort application.
@ Error
Information representing errors in application but application will keep running.
@ Debug
Informational events most useful for developers to debug application.
@ Trace
Information that can be useful to back-trace certain events - mostly useful than debug logs.
#define PERF_LOG_ALWAYS(level, cat, x)
unsigned __int64 uint64_t