MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / LogMsg

Method LogMsg

src/logging/timer.h:62–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60 }
61
62 std::string LogMsg(const std::string& msg)
63 {
64 const auto end_time{std::chrono::steady_clock::now()};
65 if (!m_start_t) {
66 return strprintf("%s: %s", m_prefix, msg);
67 }
68 const auto duration{end_time - *m_start_t};
69
70 if constexpr (std::is_same_v<TimeType, std::chrono::microseconds>) {
71 return strprintf("%s: %s (%iμs)", m_prefix, msg, Ticks<std::chrono::microseconds>(duration));
72 } else if constexpr (std::is_same_v<TimeType, std::chrono::milliseconds>) {
73 return strprintf("%s: %s (%.2fms)", m_prefix, msg, Ticks<MillisecondsDouble>(duration));
74 } else if constexpr (std::is_same_v<TimeType, std::chrono::seconds>) {
75 return strprintf("%s: %s (%.2fs)", m_prefix, msg, Ticks<SecondsDouble>(duration));
76 } else {
77 static_assert(ALWAYS_FALSE<TimeType>, "Error: unexpected time type");
78 }
79 }
80
81private:
82 std::optional<std::chrono::steady_clock::time_point> m_start_t{};

Callers 2

LogMethod · 0.95
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls

no outgoing calls

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64