13 : last(std::chrono::steady_clock::now()) {
17 auto now = std::chrono::steady_clock::now();
18 std::chrono::duration<double> diff = now - last;
19 last = std::chrono::steady_clock::now();
23 void time(
const std::string& msg =
"Time Taken: ") {
24 auto now = std::chrono::steady_clock::now();
25 std::chrono::duration<double> diff = now - last;
26 std::cout << msg << diff.count() <<
"[s]\n";
27 last = std::chrono::steady_clock::now();
31 std::chrono::steady_clock::time_point last;
34 template<
typename Time = std::chrono::microseconds,
typename Clock = std::chrono::high_resolution_clock>
36 template<
typename F,
typename... Args>
static Time
duration(F&& f, Args... args) {
37 auto start = Clock::now();
38 std::invoke(std::forward<F>(f), std::forward<Args>(args)...);
39 auto end = Clock::now();
40 return std::chrono::duration_cast<Time>(end - start);
double get_time_diff()
Definition: timer.h:16
void time(const std::string &msg="Time Taken: ")
Definition: timer.h:23
Timer()
Definition: timer.h:12
static Time duration(F &&f, Args... args)
Definition: timer.h:36