77#include < cmath>
88#include < numeric>
99#include < stdexcept>
10+ #include < utility>
1011#include < vector>
1112
1213namespace it_lab_ai {
@@ -16,7 +17,7 @@ template <typename DurationContainerType, typename DurationType, class Function,
1617DurationContainerType elapsed_time (Function&& func, Args&&... args) {
1718 auto duration = std::chrono::duration<DurationContainerType, DurationType>();
1819 auto start = std::chrono::high_resolution_clock::now ();
19- func ( args...);
20+ std::forward<Function>( func)(std::forward<Args>( args) ...);
2021 auto end = std::chrono::high_resolution_clock::now ();
2122 duration = end - start;
2223 return duration.count ();
@@ -26,7 +27,7 @@ DurationContainerType elapsed_time(Function&& func, Args&&... args) {
2627template <class Function , typename ... Args>
2728double elapsed_time_omp (Function&& func, Args&&... args) {
2829 double start = omp_get_wtime ();
29- func ( args...);
30+ std::forward<Function>( func)(std::forward<Args>( args) ...);
3031 double end = omp_get_wtime ();
3132 return end - start;
3233}
@@ -38,7 +39,7 @@ DurationContainerType elapsed_time_avg(const size_t iters, Function&& func,
3839 auto duration = std::chrono::duration<DurationContainerType, DurationType>();
3940 auto start = std::chrono::high_resolution_clock::now ();
4041 for (size_t i = 0 ; i < iters; i++) {
41- func ( args...);
42+ std::forward<Function>( func)(std::forward<Args>( args) ...);
4243 }
4344 auto end = std::chrono::high_resolution_clock::now ();
4445 duration = (end - start) / iters;
@@ -51,7 +52,7 @@ double elapsed_time_omp_avg(const size_t iters, Function&& func,
5152 Args&&... args) {
5253 double start = omp_get_wtime ();
5354 for (size_t i = 0 ; i < iters; i++) {
54- func ( args...);
55+ std::forward<Function>( func)(std::forward<Args>( args) ...);
5556 }
5657 double end = omp_get_wtime ();
5758 return (end - start) / iters;
@@ -61,26 +62,31 @@ template <typename ThroughputContainerType, typename DurationType,
6162 class Function , typename ... Args>
6263ThroughputContainerType throughput (Function&& func, Args&&... args) {
6364 return ThroughputContainerType (1 ) /
64- elapsed_time<ThroughputContainerType, DurationType>(func, args...);
65+ elapsed_time<ThroughputContainerType, DurationType>(
66+ std::forward<Function>(func), std::forward<Args>(args)...);
6567}
6668
6769template <class Function , typename ... Args>
6870double throughput_omp (Function&& func, Args&&... args) {
69- return 1 / elapsed_time_omp (func, args...);
71+ return 1 /
72+ elapsed_time_omp (std::forward<Function>(func),
73+ std::forward<Args>(args)...);
7074}
7175
7276template <typename ThroughputContainerType, typename DurationType,
7377 class Function , typename ... Args>
7478ThroughputContainerType throughput_avg (const size_t iters, Function&& func,
7579 Args&&... args) {
7680 return ThroughputContainerType (1 ) /
77- elapsed_time_avg<ThroughputContainerType, DurationType>(iters, func,
78- args...);
81+ elapsed_time_avg<ThroughputContainerType, DurationType>(
82+ iters, std::forward<Function>(func), std::forward<Args>( args) ...);
7983}
8084
8185template <class Function , typename ... Args>
8286double throughput_omp_avg (const size_t iters, Function&& func, Args&&... args) {
83- return 1 / elapsed_time_omp_avg (iters, func, args...);
87+ return 1 /
88+ elapsed_time_omp_avg (iters, std::forward<Function>(func),
89+ std::forward<Args>(args)...);
8490}
8591
8692// as "Manhattan" norm of error-vector
0 commit comments