mirror of
https://github.com/Milxnor/Project-Reboot-3.0.git
synced 2026-01-13 10:52:22 +01:00
update spdlog (it still dont work), fix 6.3(1)
This commit is contained in:
34
vendor/spdlog/stopwatch.h
vendored
34
vendor/spdlog/stopwatch.h
vendored
@@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
|
||||
// Stopwatch support for spdlog (using std::chrono::steady_clock).
|
||||
@@ -16,7 +17,8 @@
|
||||
// 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())":
|
||||
// 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>
|
||||
//..
|
||||
@@ -25,27 +27,25 @@
|
||||
// spdlog::info("Elapsed {}", duration_cast<milliseconds>(sw.elapsed())); => "Elapsed 5ms"
|
||||
|
||||
namespace spdlog {
|
||||
class stopwatch
|
||||
{
|
||||
class stopwatch {
|
||||
using clock = std::chrono::steady_clock;
|
||||
std::chrono::time_point<clock> start_tp_;
|
||||
|
||||
public:
|
||||
stopwatch()
|
||||
: start_tp_{clock::now()}
|
||||
{}
|
||||
: start_tp_{clock::now()} {}
|
||||
|
||||
std::chrono::duration<double> elapsed() const
|
||||
{
|
||||
std::chrono::duration<double> elapsed() const {
|
||||
return std::chrono::duration<double>(clock::now() - start_tp_);
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
start_tp_ = clock::now();
|
||||
std::chrono::milliseconds elapsed_ms() const {
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(clock::now() - start_tp_);
|
||||
}
|
||||
|
||||
void reset() { start_tp_ = clock::now(); }
|
||||
};
|
||||
} // namespace spdlog
|
||||
} // namespace spdlog
|
||||
|
||||
// Support for fmt formatting (e.g. "{:012.9}" or just "{}")
|
||||
namespace
|
||||
@@ -56,13 +56,11 @@ namespace
|
||||
#endif
|
||||
{
|
||||
|
||||
template<>
|
||||
struct formatter<spdlog::stopwatch> : formatter<double>
|
||||
{
|
||||
template<typename FormatContext>
|
||||
auto format(const spdlog::stopwatch &sw, FormatContext &ctx) -> decltype(ctx.out())
|
||||
{
|
||||
template <>
|
||||
struct formatter<spdlog::stopwatch> : formatter<double> {
|
||||
template <typename FormatContext>
|
||||
auto format(const spdlog::stopwatch &sw, FormatContext &ctx) const -> decltype(ctx.out()) {
|
||||
return formatter<double>::format(sw.elapsed().count(), ctx);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
} // namespace std
|
||||
|
||||
Reference in New Issue
Block a user