20 lines
558 B
C++
20 lines
558 B
C++
#ifndef TESTRUNNER_HPP
|
|
#define TESTRUNNER_HPP
|
|
|
|
#include <chrono>
|
|
|
|
// function template executing given function with one argument, measuring execution time
|
|
template <typename Func, typename Arg1>
|
|
double TestRunner(Func func, Arg1& arg1)
|
|
{
|
|
std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
|
|
func(arg1);
|
|
std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now();
|
|
std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double>>(t2 - t1);
|
|
|
|
return time_span.count();
|
|
}
|
|
|
|
|
|
#endif
|