1#ifndef TATOOINE_CHRONO_H
2#define TATOOINE_CHRONO_H
10template <
typename F,
typename... Param>
12 using time = std::chrono::high_resolution_clock;
13 using f_return_type =
decltype(f(std::forward<Param>(param)...));
15 auto before = time::now();
17 if constexpr (std::is_same_v<f_return_type, void>) {
18 f(std::forward<Param>(param)...);
19 return time::now() - before;
22 decltype(
auto) ret = f(std::forward<Param>(param)...);
23 auto duration = time::now() - before;
24 return std::pair<
decltype(duration),
decltype(ret)>{duration, ret};
28template <
typename... Durations,
typename DurationIn>
30 using namespace std::chrono;
31 std::tuple<Durations...> retval;
32 (((std::get<Durations>(retval) = duration_cast<Durations>(d)),
33 (d -= duration_cast<DurationIn>(std::get<Durations>(retval)))),
Definition: algorithm.h:6
auto break_down_durations(DurationIn d)
Definition: chrono.h:29
auto measure(F &&f, Param &&... param)
Definition: chrono.h:11