Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
performance_test.cpp
Go to the documentation of this file.
1#include "gtest/gtest.h"
2#include "rclcpp/rclcpp.hpp"
4
5
9void iterate_smoothing(const std::vector<PathPoint> &path) {
10 auto path_smoothing = PathSmoothing();
11
12 std::ofstream measures_path = ::openWriteFile("performance/exec_time/planning/planning_" +
14 double total_time = 0;
15 int no_iters = 100;
16
17 // No_iters repetitions to get average
18 for (int i = 0; i < no_iters; i++) {
19
20 auto t0 = std::chrono::high_resolution_clock::now();
21
22 std::vector<PathPoint> smoothed_path =
23 path_smoothing.smooth_path(path,false);
24
25 auto t1 = std::chrono::high_resolution_clock::now();
26
27 double elapsed_time_ms = std::chrono::duration<double, std::milli>(t1 - t0).count();
28
29 total_time += elapsed_time_ms;
30 }
31
32 measures_path << total_time / no_iters << "\n";
33 measures_path.close();
34
35 RCLCPP_INFO(rclcpp::get_logger("rclcpp"), "Average Smoothing processed in %f ms.",
36 (total_time / no_iters));
37}
class that defines the path smoothing algorithm
Definition smoothing.hpp:22
std::ofstream openWriteFile(const std::string &filename, const std::string &header="")
Definition files.cpp:21
void iterate_smoothing(const std::vector< PathPoint > &path)
Iterates the Smoothing algorithm repeatedly and measures the average time.
std::string get_current_date_time_as_string()
Get current date and time as a string.
Definition utils.cpp:125