From 5dc738a57930271194bd86673eb86f149096a7b2 Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 19 Mar 2019 16:21:54 +0800 Subject: ... --- src/cru_debug.hpp | 67 +++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 34 deletions(-) (limited to 'src/cru_debug.hpp') diff --git a/src/cru_debug.hpp b/src/cru_debug.hpp index 17cc7b53..9c22a24f 100644 --- a/src/cru_debug.hpp +++ b/src/cru_debug.hpp @@ -1,47 +1,46 @@ #pragma once - -// ReSharper disable once CppUnusedIncludeDirective #include "pre.hpp" #include #include "base.hpp" -#include "format.hpp" +#include "util/format.hpp" -namespace cru::debug -{ - void DebugMessage(const StringView& message); +namespace cru::debug { +void DebugMessage(const StringView& message); #ifdef CRU_DEBUG - inline void DebugTime(const std::function& action, const StringView& hint_message) - { - const auto before = std::chrono::steady_clock::now(); - action(); - const auto after = std::chrono::steady_clock::now(); - const auto duration = std::chrono::duration_cast(after - before); - DebugMessage(Format(L"{}: {}ms.\n", hint_message, duration.count())); - } +inline void DebugTime(const std::function& action, + const StringView& hint_message) { + const auto before = std::chrono::steady_clock::now(); + action(); + const auto after = std::chrono::steady_clock::now(); + const auto duration = + std::chrono::duration_cast(after - before); + DebugMessage(util::Format(L"{}: {}ms.\n", hint_message, duration.count())); +} - template - TReturn DebugTime(const std::function& action, const StringView& hint_message) - { - const auto before = std::chrono::steady_clock::now(); - auto&& result = action(); - const auto after = std::chrono::steady_clock::now(); - const auto duration = std::chrono::duration_cast(after - before); - DebugMessage(Format(L"{}: {}ms.\n", hint_message, duration.count())); - return std::move(result); - } +template +TReturn DebugTime(const std::function& action, + const StringView& hint_message) { + const auto before = std::chrono::steady_clock::now(); + auto&& result = action(); + const auto after = std::chrono::steady_clock::now(); + const auto duration = + std::chrono::duration_cast(after - before); + DebugMessage(util::Format(L"{}: {}ms.\n", hint_message, duration.count())); + return std::move(result); +} #else - inline void DebugTime(const std::function& action, const StringView& hint_message) - { - action(); - } +inline void DebugTime(const std::function& action, + const StringView& hint_message) { + action(); +} - template - TReturn DebugTime(const std::function& action, const StringView& hint_message) - { - return action(); - } -#endif +template +TReturn DebugTime(const std::function& action, + const StringView& hint_message) { + return action(); } +#endif +} // namespace cru::debug -- cgit v1.2.3