I wanted to have a function called timeit which can measure the time of execution of n iterations of any other function. I still learning C++ but I come up with that : Any thought ?
#include<chrono>
using namespace std;
template<typename output, typename ...ArgsT, typename ...Input>
double timeit(output (*function)(Input...), int n, ArgsT ...args)
{
auto start = chrono::high_resolution_clock::now();
for(int k = 0; k < n; ++k)
{
function(args...);
}
auto end = chrono::high_resolution_clock::now();
chrono::duration<double> elapsed = (end-start);
return elapsed.count();
}