Comment the Utils section

This commit is contained in:
2021-10-13 18:05:54 +02:00
parent 51c3203fda
commit 1cf6795130
3 changed files with 63 additions and 31 deletions

View File

@@ -1,4 +1,4 @@
// [[file:../../atrip.org::*Utils][Utils:1]]
// [[file:../../atrip.org::*Prolog][Prolog:1]]
#pragma once
#include <sstream>
#include <string>
@@ -8,9 +8,10 @@
#include <ctf.hpp>
namespace atrip {
// Prolog:1 ends here
template <typename T>
// [[file:../../atrip.org::*Pretty printing][Pretty printing:1]]
template <typename T>
std::string pretty_print(T&& value) {
std::stringstream stream;
#if ATRIP_DEBUG > 1
@@ -18,20 +19,27 @@ namespace atrip {
#endif
return stream.str();
}
// Pretty printing:1 ends here
#define WITH_CHRONO(__chrono, ...) \
__chrono.start(); __VA_ARGS__ __chrono.stop();
// [[file:../../atrip.org::*Chrono][Chrono:1]]
#define WITH_CHRONO(__chrono, ...) \
__chrono.start(); \
__VA_ARGS__ \
__chrono.stop();
struct Timer {
using Clock = std::chrono::high_resolution_clock;
using Event = std::chrono::time_point<Clock>;
std::chrono::duration<double> duration;
Event _start;
inline void start() noexcept { _start = Clock::now(); }
inline void stop() noexcept { duration += Clock::now() - _start; }
inline void clear() noexcept { duration *= 0; }
inline double count() const noexcept { return duration.count(); }
};
using Timings = std::map<std::string, Timer>;
struct Timer {
using Clock = std::chrono::high_resolution_clock;
using Event = std::chrono::time_point<Clock>;
std::chrono::duration<double> duration;
Event _start;
inline void start() noexcept { _start = Clock::now(); }
inline void stop() noexcept { duration += Clock::now() - _start; }
inline void clear() noexcept { duration *= 0; }
inline double count() const noexcept { return duration.count(); }
};
using Timings = std::map<std::string, Timer>;
// Chrono:1 ends here
// [[file:../../atrip.org::*Epilog][Epilog:1]]
}
// Utils:1 ends here
// Epilog:1 ends here