mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
perf_timer: separate log categories based on caller categories
Also default to microseconds, for homogeneity Makes it easier to enable what we need
This commit is contained in:
parent
5c85da5a73
commit
ca9b996dcb
2 changed files with 12 additions and 14 deletions
|
@ -104,11 +104,11 @@ PerformanceTimer::PerformanceTimer(bool paused): started(true), paused(paused)
|
||||||
ticks = get_tick_count();
|
ticks = get_tick_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
LoggingPerformanceTimer::LoggingPerformanceTimer(const std::string &s, uint64_t unit, el::Level l): PerformanceTimer(), name(s), unit(unit), level(l)
|
LoggingPerformanceTimer::LoggingPerformanceTimer(const std::string &s, const std::string &cat, uint64_t unit, el::Level l): PerformanceTimer(), name(s), cat(cat), unit(unit), level(l)
|
||||||
{
|
{
|
||||||
if (!performance_timers)
|
if (!performance_timers)
|
||||||
{
|
{
|
||||||
MLOG(level, "PERF ----------");
|
MCLOG(level, cat.c_str(), "PERF ----------");
|
||||||
performance_timers = new std::vector<LoggingPerformanceTimer*>();
|
performance_timers = new std::vector<LoggingPerformanceTimer*>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -117,7 +117,7 @@ LoggingPerformanceTimer::LoggingPerformanceTimer(const std::string &s, uint64_t
|
||||||
if (!pt->started && !pt->paused)
|
if (!pt->started && !pt->paused)
|
||||||
{
|
{
|
||||||
size_t size = 0; for (const auto *tmp: *performance_timers) if (!tmp->paused) ++size;
|
size_t size = 0; for (const auto *tmp: *performance_timers) if (!tmp->paused) ++size;
|
||||||
MLOG(pt->level, "PERF " << std::string((size-1) * 2, ' ') << " " << pt->name);
|
MCLOG(pt->level, cat.c_str(), "PERF " << std::string((size-1) * 2, ' ') << " " << pt->name);
|
||||||
pt->started = true;
|
pt->started = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ LoggingPerformanceTimer::~LoggingPerformanceTimer()
|
||||||
char s[12];
|
char s[12];
|
||||||
snprintf(s, sizeof(s), "%8llu ", (unsigned long long)(ticks_to_ns(ticks) / (1000000000 / unit)));
|
snprintf(s, sizeof(s), "%8llu ", (unsigned long long)(ticks_to_ns(ticks) / (1000000000 / unit)));
|
||||||
size_t size = 0; for (const auto *tmp: *performance_timers) if (!tmp->paused || tmp==this) ++size;
|
size_t size = 0; for (const auto *tmp: *performance_timers) if (!tmp->paused || tmp==this) ++size;
|
||||||
MLOG(level, "PERF " << s << std::string(size * 2, ' ') << " " << name);
|
MCLOG(level, cat.c_str(), "PERF " << s << std::string(size * 2, ' ') << " " << name);
|
||||||
if (performance_timers->empty())
|
if (performance_timers->empty())
|
||||||
{
|
{
|
||||||
delete performance_timers;
|
delete performance_timers;
|
||||||
|
|
|
@ -33,9 +33,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "misc_log_ex.h"
|
#include "misc_log_ex.h"
|
||||||
|
|
||||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
|
||||||
#define MONERO_DEFAULT_LOG_CATEGORY "perf"
|
|
||||||
|
|
||||||
namespace tools
|
namespace tools
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -67,23 +64,24 @@ protected:
|
||||||
class LoggingPerformanceTimer: public PerformanceTimer
|
class LoggingPerformanceTimer: public PerformanceTimer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LoggingPerformanceTimer(const std::string &s, uint64_t unit, el::Level l = el::Level::Debug);
|
LoggingPerformanceTimer(const std::string &s, const std::string &cat, uint64_t unit, el::Level l = el::Level::Debug);
|
||||||
~LoggingPerformanceTimer();
|
~LoggingPerformanceTimer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::string cat;
|
||||||
uint64_t unit;
|
uint64_t unit;
|
||||||
el::Level level;
|
el::Level level;
|
||||||
};
|
};
|
||||||
|
|
||||||
void set_performance_timer_log_level(el::Level level);
|
void set_performance_timer_log_level(el::Level level);
|
||||||
|
|
||||||
#define PERF_TIMER_UNIT(name, unit) tools::LoggingPerformanceTimer pt_##name(#name, unit, tools::performance_timer_log_level)
|
#define PERF_TIMER_UNIT(name, unit) tools::LoggingPerformanceTimer pt_##name(#name, "perf." MONERO_DEFAULT_LOG_CATEGORY, unit, tools::performance_timer_log_level)
|
||||||
#define PERF_TIMER_UNIT_L(name, unit, l) tools::LoggingPerformanceTimer pt_##name(#name, unit, l)
|
#define PERF_TIMER_UNIT_L(name, unit, l) tools::LoggingPerformanceTimer pt_##name(#name, "perf." MONERO_DEFAULT_LOG_CATEGORY, unit, l)
|
||||||
#define PERF_TIMER(name) PERF_TIMER_UNIT(name, 1000)
|
#define PERF_TIMER(name) PERF_TIMER_UNIT(name, 1000000)
|
||||||
#define PERF_TIMER_L(name, l) PERF_TIMER_UNIT_L(name, 1000, l)
|
#define PERF_TIMER_L(name, l) PERF_TIMER_UNIT_L(name, 1000000, l)
|
||||||
#define PERF_TIMER_START_UNIT(name, unit) std::unique_ptr<tools::LoggingPerformanceTimer> pt_##name(new tools::LoggingPerformanceTimer(#name, unit, el::Level::Info))
|
#define PERF_TIMER_START_UNIT(name, unit) std::unique_ptr<tools::LoggingPerformanceTimer> pt_##name(new tools::LoggingPerformanceTimer(#name, "perf." MONERO_DEFAULT_LOG_CATEGORY, unit, el::Level::Info))
|
||||||
#define PERF_TIMER_START(name) PERF_TIMER_START_UNIT(name, 1000)
|
#define PERF_TIMER_START(name) PERF_TIMER_START_UNIT(name, 1000000)
|
||||||
#define PERF_TIMER_STOP(name) do { pt_##name.reset(NULL); } while(0)
|
#define PERF_TIMER_STOP(name) do { pt_##name.reset(NULL); } while(0)
|
||||||
#define PERF_TIMER_PAUSE(name) pt_##name->pause()
|
#define PERF_TIMER_PAUSE(name) pt_##name->pause()
|
||||||
#define PERF_TIMER_RESUME(name) pt_##name->resume()
|
#define PERF_TIMER_RESUME(name) pt_##name->resume()
|
||||||
|
|
Loading…
Reference in a new issue