11 #ifndef BEMBEL_SRC_IO_STOPWATCH_HPP_
12 #define BEMBEL_SRC_IO_STOPWATCH_HPP_
28 std::chrono::time_point<std::chrono::high_resolution_clock> p_;
30 std::vector<double> durations_;
31 bool has_been_started_;
36 has_been_started_ =
false;
40 void tic(
void) { p_ = std::chrono::high_resolution_clock::now(); }
42 double dtime = std::chrono::duration<double, std::ratio<1, 1>>(
43 std::chrono::high_resolution_clock::now() - p_)
49 assert(has_been_started_ ==
false &&
"Stopwatch already running!");
50 has_been_started_ =
true;
51 p_ = std::chrono::high_resolution_clock::now();
54 double out = std::chrono::duration<double, std::ratio<1, 1>>(
55 std::chrono::high_resolution_clock::now() - p_)
57 durations_.push_back(out);
58 assert(has_been_started_ ==
true &&
"Stopwatch must be started first!");
60 p_ = std::chrono::high_resolution_clock::now();
63 inline double stop() {
64 double out = std::chrono::duration<double, std::ratio<1, 1>>(
65 std::chrono::high_resolution_clock::now() - p_)
67 assert(has_been_started_ ==
true &&
"Stopwatch must be started first!");
70 has_been_started_ =
false;
71 return std::accumulate(durations_.begin(), durations_.end(), 0.0);
75 inline std::vector<double> get_data() {
return durations_; }
A simple class for benchmarking.
Routines for the evalutation of pointwise errors.