diff options
author | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-07-07 21:31:41 +0100 |
---|---|---|
committer | BobTheBob9 <for.oliver.kirkham@gmail.com> | 2022-07-07 21:31:41 +0100 |
commit | 2ae34b67e36b8ba05132d481876eb4ed7a826283 (patch) | |
tree | 63f44c8e2dcdc959d7a5317a3a7b36efedbd7d38 /NorthstarDLL/include/spdlog/stopwatch.h | |
parent | 3406de7aaaf52cbef20b1549f2d7da0255d30f51 (diff) | |
download | NorthstarLauncher-2ae34b67e36b8ba05132d481876eb4ed7a826283.tar.gz NorthstarLauncher-2ae34b67e36b8ba05132d481876eb4ed7a826283.zip |
almost fully replaced hooking lib
Diffstat (limited to 'NorthstarDLL/include/spdlog/stopwatch.h')
-rw-r--r-- | NorthstarDLL/include/spdlog/stopwatch.h | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/NorthstarDLL/include/spdlog/stopwatch.h b/NorthstarDLL/include/spdlog/stopwatch.h index bb976b19..67f8376d 100644 --- a/NorthstarDLL/include/spdlog/stopwatch.h +++ b/NorthstarDLL/include/spdlog/stopwatch.h @@ -1,61 +1,61 @@ -// Copyright(c) 2015-present, Gabi Melman & spdlog contributors. -// Distributed under the MIT License (http://opensource.org/licenses/MIT) - -#pragma once - -#include <spdlog/fmt/fmt.h> - -// Stopwatch support for spdlog (using std::chrono::steady_clock). -// Displays elapsed seconds since construction as double. -// -// Usage: -// -// spdlog::stopwatch sw; -// ... -// spdlog::debug("Elapsed: {} seconds", sw); => "Elapsed 0.005116733 seconds" -// spdlog::info("Elapsed: {:.6} seconds", sw); => "Elapsed 0.005163 seconds" -// -// -// If other units are needed (e.g. millis instead of double), include "fmt/chrono.h" and use "duration_cast<..>(sw.elapsed())": -// -// #include <spdlog/fmt/chrono.h> -//.. -// using std::chrono::duration_cast; -// using std::chrono::milliseconds; -// spdlog::info("Elapsed {}", duration_cast<milliseconds>(sw.elapsed())); => "Elapsed 5ms" - -namespace spdlog { -class stopwatch -{ - using clock = std::chrono::steady_clock; - std::chrono::time_point<clock> start_tp_; - -public: - stopwatch() - : start_tp_{clock::now()} - {} - - std::chrono::duration<double> elapsed() const - { - return std::chrono::duration<double>(clock::now() - start_tp_); - } - - void reset() - { - start_tp_ = clock ::now(); - } -}; -} // namespace spdlog - -// Support for fmt formatting (e.g. "{:012.9}" or just "{}") -namespace fmt { -template<> -struct formatter<spdlog::stopwatch> : formatter<double> -{ - template<typename FormatContext> - auto format(const spdlog::stopwatch &sw, FormatContext &ctx) -> decltype(ctx.out()) - { - return formatter<double>::format(sw.elapsed().count(), ctx); - } -}; -} // namespace fmt +// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
+// Distributed under the MIT License (http://opensource.org/licenses/MIT)
+
+#pragma once
+
+#include <spdlog/fmt/fmt.h>
+
+// Stopwatch support for spdlog (using std::chrono::steady_clock).
+// Displays elapsed seconds since construction as double.
+//
+// Usage:
+//
+// spdlog::stopwatch sw;
+// ...
+// spdlog::debug("Elapsed: {} seconds", sw); => "Elapsed 0.005116733 seconds"
+// spdlog::info("Elapsed: {:.6} seconds", sw); => "Elapsed 0.005163 seconds"
+//
+//
+// If other units are needed (e.g. millis instead of double), include "fmt/chrono.h" and use "duration_cast<..>(sw.elapsed())":
+//
+// #include <spdlog/fmt/chrono.h>
+//..
+// using std::chrono::duration_cast;
+// using std::chrono::milliseconds;
+// spdlog::info("Elapsed {}", duration_cast<milliseconds>(sw.elapsed())); => "Elapsed 5ms"
+
+namespace spdlog {
+class stopwatch
+{
+ using clock = std::chrono::steady_clock;
+ std::chrono::time_point<clock> start_tp_;
+
+public:
+ stopwatch()
+ : start_tp_{clock::now()}
+ {}
+
+ std::chrono::duration<double> elapsed() const
+ {
+ return std::chrono::duration<double>(clock::now() - start_tp_);
+ }
+
+ void reset()
+ {
+ start_tp_ = clock ::now();
+ }
+};
+} // namespace spdlog
+
+// Support for fmt formatting (e.g. "{:012.9}" or just "{}")
+namespace fmt {
+template<>
+struct formatter<spdlog::stopwatch> : formatter<double>
+{
+ template<typename FormatContext>
+ auto format(const spdlog::stopwatch &sw, FormatContext &ctx) -> decltype(ctx.out())
+ {
+ return formatter<double>::format(sw.elapsed().count(), ctx);
+ }
+};
+} // namespace fmt
|