diff --git a/Makefile b/Makefile index 933ce0d..b9e0f4a 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ CONFIG ?= gcc PREFIX ?= /usr SOURCES_FILE := Sources.mk +-include config.mk include $(SOURCES_FILE) include ./etc/make/emacs.mk include ./etc/config/$(CONFIG).mk diff --git a/atrip.org b/atrip.org index c4840bf..5c333e2 100644 --- a/atrip.org +++ b/atrip.org @@ -710,6 +710,9 @@ std::ostream& operator<<(std::ostream& out, Slice::Info const& i) { #+end_src ** Utils + +This section presents some utilities +*** Prolog :noexport: #+begin_src c++ :tangle (atrip-utils-h) #pragma once #include @@ -720,8 +723,13 @@ std::ostream& operator<<(std::ostream& out, Slice::Info const& i) { #include namespace atrip { +#+end_src +*** Pretty printing +The pretty printing uses the [[https://github.com/sharkdp/dbg-macro][dbg-macro]] package. + +#+begin_src c++ :tangle (atrip-utils-h) template std::string pretty_print(T&& value) { std::stringstream stream; @@ -731,22 +739,37 @@ namespace atrip { return stream.str(); } -#define WITH_CHRONO(__chrono, ...) \ - __chrono.start(); __VA_ARGS__ __chrono.stop(); +#+end_src - struct Timer { - using Clock = std::chrono::high_resolution_clock; - using Event = std::chrono::time_point; - std::chrono::duration 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; +*** Chrono + +The chrono is just a simple wrapper for a high resolution clock +that can be found in the =std::chrono= namespace of the standard library. + +#+begin_src c++ :tangle (atrip-utils-h) +#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; + std::chrono::duration 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; + +#+end_src + + +*** Epilog :noexport: +#+begin_src c++ :tangle (atrip-utils-h) } - #+end_src ** The rank mapping diff --git a/include/atrip/Utils.hpp b/include/atrip/Utils.hpp index a6bd743..bf17398 100644 --- a/include/atrip/Utils.hpp +++ b/include/atrip/Utils.hpp @@ -1,4 +1,4 @@ -// [[file:../../atrip.org::*Utils][Utils:1]] +// [[file:../../atrip.org::*Prolog][Prolog:1]] #pragma once #include #include @@ -8,9 +8,10 @@ #include namespace atrip { +// Prolog:1 ends here - - template +// [[file:../../atrip.org::*Pretty printing][Pretty printing:1]] +template 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; - std::chrono::duration 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; +struct Timer { + using Clock = std::chrono::high_resolution_clock; + using Event = std::chrono::time_point; + std::chrono::duration 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; +// Chrono:1 ends here + +// [[file:../../atrip.org::*Epilog][Epilog:1]] } -// Utils:1 ends here +// Epilog:1 ends here