| 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 | |
| 81 | private: |
| 82 | std::optional<std::chrono::steady_clock::time_point> m_start_t{}; |
no outgoing calls