You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
526 B
20 lines
526 B
#pragma once
|
|
|
|
#include <chrono>
|
|
#include <iostream>
|
|
|
|
template<typename Callable>
|
|
void measure_time(Callable&& callable) {
|
|
using namespace std::chrono;
|
|
steady_clock::time_point t_start = steady_clock::now();
|
|
callable();
|
|
duration<double> time_span = duration_cast<duration<double>>(steady_clock::now() - t_start);
|
|
|
|
std::cout << "took " << time_span.count() << " seconds\n";
|
|
}
|
|
|
|
template<typename Callable>
|
|
void measure_time_with_dry_run(Callable&& callable) {
|
|
callable();
|
|
measure_time(std::forward<Callable>(callable));
|
|
}
|