robotoc
robotoc - efficient ROBOT Optimal Control solvers
Loading...
Searching...
No Matches
ocp_benchmarker.hxx
Go to the documentation of this file.
1#ifndef ROBOTOC_UTILS_OCP_BENCHMARKER_HXX_
2#define ROBOTOC_UTILS_OCP_BENCHMARKER_HXX_
3
5
6#include <iostream>
7#include <chrono>
8
9
10namespace robotoc {
11namespace benchmark {
12
13template <typename OCPSolverType>
14inline void CPUTime(OCPSolverType& ocp_solver, const double t,
15 const Eigen::VectorXd& q, const Eigen::VectorXd& v,
16 const int num_iteration) {
17 std::chrono::high_resolution_clock::time_point start_clock, end_clock;
18 start_clock = std::chrono::high_resolution_clock::now();
19 for (int i=0; i<num_iteration; ++i) {
20 ocp_solver.updateSolution(t, q, v);
21 }
22 end_clock = std::chrono::high_resolution_clock::now();
23 std::chrono::duration<double, std::milli> timing = end_clock - start_clock;
24 std::cout << "---------- OCP benchmark : CPU time ----------" << std::endl;
25 std::cout << "total CPU time: " << timing.count()
26 << "[ms]" << std::endl;
27 std::cout << "CPU time per update: " << timing.count() / num_iteration
28 << "[ms]" << std::endl;
29 std::cout << "-----------------------------------" << std::endl;
30 std::cout << std::endl;
31}
32
33} // namespace benchmark
34} // namespace robotoc
35
36#endif // ROBOTOC_UTILS_OCP_BENCHMARKER_HXX_
void CPUTime(OCPSolverType &ocp_solver, const double t, const Eigen::VectorXd &q, const Eigen::VectorXd &v, const int num_iteration=1000)
Definition: ocp_benchmarker.hxx:14
Definition: constraint_component_base.hpp:17