+ /*!
+ \brief Run the given function and return the mean run time and stddev.
+ \param [in] function Function to benchmark.
+ \param [in] args Function's arguments.
+ \return std::pair where the first element is mean and the second one is standard deviation.
+ */
+ template <typename F, typename ... Args>
+ std::pair<double, double> run_benchmark(F function, Args ... args)
+ {
+ std::vector<long> results((unsigned long) BenchmarkParameters::repetition);
+
+ for(unsigned int outer_loop = 0; outer_loop < BenchmarkParameters::repetition; outer_loop++) {
+ const auto start_time = __rdtsc();
+ for (unsigned int inner_loop = 0; inner_loop < BenchmarkParameters::loop; inner_loop++) {
+ function(args ...);
+ }
+ const auto end_time = __rdtsc();
+ results.push_back(end_time - start_time);
+ }
+
+ return calculate_statistics(results);
+ };
+