I am trying to use time() to measure various points of my program.
What I don\'t understand is why the values in the before and after are the same? I understand thi
I usually use the following:
#include
#include
using perf_clock = std::conditional<
std::chrono::high_resolution_clock::is_steady,
std::chrono::high_resolution_clock,
std::chrono::steady_clock
>::type;
using floating_seconds = std::chrono::duration;
template
floating_seconds run_test(Func&& func, Args&&... args)
{
const auto t0 = perf_clock::now();
std::forward(func)(std::forward(args)...);
return floating_seconds(perf_clock::now() - t0);
}
It's the same as @nikos-athanasiou proposed except that I avoid using of a non-steady clock and use floating number of seconds as a duration.