Comment the Utils section
This commit is contained in:
parent
51c3203fda
commit
1cf6795130
1
Makefile
1
Makefile
@ -3,6 +3,7 @@ CONFIG ?= gcc
|
|||||||
PREFIX ?= /usr
|
PREFIX ?= /usr
|
||||||
SOURCES_FILE := Sources.mk
|
SOURCES_FILE := Sources.mk
|
||||||
|
|
||||||
|
-include config.mk
|
||||||
include $(SOURCES_FILE)
|
include $(SOURCES_FILE)
|
||||||
include ./etc/make/emacs.mk
|
include ./etc/make/emacs.mk
|
||||||
include ./etc/config/$(CONFIG).mk
|
include ./etc/config/$(CONFIG).mk
|
||||||
|
|||||||
51
atrip.org
51
atrip.org
@ -710,6 +710,9 @@ std::ostream& operator<<(std::ostream& out, Slice::Info const& i) {
|
|||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Utils
|
** Utils
|
||||||
|
|
||||||
|
This section presents some utilities
|
||||||
|
*** Prolog :noexport:
|
||||||
#+begin_src c++ :tangle (atrip-utils-h)
|
#+begin_src c++ :tangle (atrip-utils-h)
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -720,8 +723,13 @@ std::ostream& operator<<(std::ostream& out, Slice::Info const& i) {
|
|||||||
#include <ctf.hpp>
|
#include <ctf.hpp>
|
||||||
|
|
||||||
namespace atrip {
|
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 <typename T>
|
template <typename T>
|
||||||
std::string pretty_print(T&& value) {
|
std::string pretty_print(T&& value) {
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
@ -731,22 +739,37 @@ namespace atrip {
|
|||||||
return stream.str();
|
return stream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WITH_CHRONO(__chrono, ...) \
|
#+end_src
|
||||||
__chrono.start(); __VA_ARGS__ __chrono.stop();
|
|
||||||
|
|
||||||
struct Timer {
|
*** Chrono
|
||||||
using Clock = std::chrono::high_resolution_clock;
|
|
||||||
using Event = std::chrono::time_point<Clock>;
|
The chrono is just a simple wrapper for a high resolution clock
|
||||||
std::chrono::duration<double> duration;
|
that can be found in the =std::chrono= namespace of the standard library.
|
||||||
Event _start;
|
|
||||||
inline void start() noexcept { _start = Clock::now(); }
|
#+begin_src c++ :tangle (atrip-utils-h)
|
||||||
inline void stop() noexcept { duration += Clock::now() - _start; }
|
#define WITH_CHRONO(__chrono, ...) \
|
||||||
inline void clear() noexcept { duration *= 0; }
|
__chrono.start(); \
|
||||||
inline double count() const noexcept { return duration.count(); }
|
__VA_ARGS__ \
|
||||||
};
|
__chrono.stop();
|
||||||
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>;
|
||||||
|
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
|
||||||
|
*** Epilog :noexport:
|
||||||
|
#+begin_src c++ :tangle (atrip-utils-h)
|
||||||
}
|
}
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** The rank mapping
|
** The rank mapping
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// [[file:../../atrip.org::*Utils][Utils:1]]
|
// [[file:../../atrip.org::*Prolog][Prolog:1]]
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -8,9 +8,10 @@
|
|||||||
#include <ctf.hpp>
|
#include <ctf.hpp>
|
||||||
|
|
||||||
namespace atrip {
|
namespace atrip {
|
||||||
|
// Prolog:1 ends here
|
||||||
|
|
||||||
|
// [[file:../../atrip.org::*Pretty printing][Pretty printing:1]]
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::string pretty_print(T&& value) {
|
std::string pretty_print(T&& value) {
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
#if ATRIP_DEBUG > 1
|
#if ATRIP_DEBUG > 1
|
||||||
@ -18,20 +19,27 @@ namespace atrip {
|
|||||||
#endif
|
#endif
|
||||||
return stream.str();
|
return stream.str();
|
||||||
}
|
}
|
||||||
|
// Pretty printing:1 ends here
|
||||||
|
|
||||||
#define WITH_CHRONO(__chrono, ...) \
|
// [[file:../../atrip.org::*Chrono][Chrono:1]]
|
||||||
__chrono.start(); __VA_ARGS__ __chrono.stop();
|
#define WITH_CHRONO(__chrono, ...) \
|
||||||
|
__chrono.start(); \
|
||||||
|
__VA_ARGS__ \
|
||||||
|
__chrono.stop();
|
||||||
|
|
||||||
struct Timer {
|
struct Timer {
|
||||||
using Clock = std::chrono::high_resolution_clock;
|
using Clock = std::chrono::high_resolution_clock;
|
||||||
using Event = std::chrono::time_point<Clock>;
|
using Event = std::chrono::time_point<Clock>;
|
||||||
std::chrono::duration<double> duration;
|
std::chrono::duration<double> duration;
|
||||||
Event _start;
|
Event _start;
|
||||||
inline void start() noexcept { _start = Clock::now(); }
|
inline void start() noexcept { _start = Clock::now(); }
|
||||||
inline void stop() noexcept { duration += Clock::now() - _start; }
|
inline void stop() noexcept { duration += Clock::now() - _start; }
|
||||||
inline void clear() noexcept { duration *= 0; }
|
inline void clear() noexcept { duration *= 0; }
|
||||||
inline double count() const noexcept { return duration.count(); }
|
inline double count() const noexcept { return duration.count(); }
|
||||||
};
|
};
|
||||||
using Timings = std::map<std::string, Timer>;
|
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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user