 |
Bitcoin Core
21.99.0
P2P Digital Currency
|
Go to the documentation of this file.
6 #ifndef BITCOIN_LOGGING_TIMER_H
7 #define BITCOIN_LOGGING_TIMER_H
20 template <
typename TimeType>
35 m_start_t = GetTime<std::chrono::microseconds>();
43 void Log(
const std::string& msg)
45 const std::string full_msg = this->
LogMsg(msg);
54 std::string
LogMsg(
const std::string& msg)
56 const auto end_time = GetTime<std::chrono::microseconds>() -
m_start_t;
61 std::string units =
"";
64 if (std::is_same<TimeType, std::chrono::microseconds>::value) {
66 }
else if (std::is_same<TimeType, std::chrono::milliseconds>::value) {
69 }
else if (std::is_same<TimeType, std::chrono::seconds>::value) {
71 divisor = 1000. * 1000.;
74 const float time_ms = end_time.count() / divisor;
96 #define LOG_TIME_MILLIS_WITH_CATEGORY(end_msg, log_category) \
97 BCLog::Timer<std::chrono::milliseconds> PASTE2(logging_timer, __COUNTER__)(__func__, end_msg, log_category)
98 #define LOG_TIME_SECONDS(end_msg) \
99 BCLog::Timer<std::chrono::seconds> PASTE2(logging_timer, __COUNTER__)(__func__, end_msg)
102 #endif // BITCOIN_LOGGING_TIMER_H
RAII-style object that outputs timing information to logs.
std::string LogMsg(const std::string &msg)
Timer(std::string prefix, std::string end_msg, BCLog::LogFlags log_category=BCLog::LogFlags::ALL)
If log_category is left as the default, end_msg will log unconditionally (instead of being filtered b...
const std::string m_title
A descriptive message of what is being timed.
void Log(const std::string &msg)
const BCLog::LogFlags m_log_category
Forwarded on to LogPrint if specified - has the effect of only outputting the timing log when a parti...
#define LogPrint(category,...)
const std::string m_prefix
Log prefix; usually the name of the function this was created in.
std::chrono::microseconds m_start_t