From 5417a4ab9d1e9fcd60bfb66801731f14c1c1a255 Mon Sep 17 00:00:00 2001 From: Wolfgang Hess Date: Tue, 11 Jul 2017 14:57:30 +0200 Subject: [PATCH] Add performance info to the offline node. (#420) Outputs elapsed wall clock time and process CPU usage when the node finishes. --- .../cartographer_ros/offline_node_main.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cartographer_ros/cartographer_ros/offline_node_main.cc b/cartographer_ros/cartographer_ros/offline_node_main.cc index 583e4a4..af41cc2 100644 --- a/cartographer_ros/cartographer_ros/offline_node_main.cc +++ b/cartographer_ros/cartographer_ros/offline_node_main.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include +#include #include #include #include @@ -81,6 +83,8 @@ std::tuple LoadOptions() { } void Run(const std::vector& bag_filenames) { + const std::chrono::time_point start_time = + std::chrono::steady_clock::now(); NodeOptions node_options; TrajectoryOptions trajectory_options; std::tie(node_options, trajectory_options) = LoadOptions(); @@ -260,6 +264,21 @@ void Run(const std::vector& bag_filenames) { node.map_builder_bridge()->FinishTrajectory(trajectory_id); } + const std::chrono::time_point end_time = + std::chrono::steady_clock::now(); + const double wall_clock_seconds = + std::chrono::duration_cast>(end_time - + start_time) + .count(); + + LOG(INFO) << "Elapsed wall clock time: " << wall_clock_seconds << " s"; +#ifdef __linux__ + timespec cpu_timespec = {}; + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cpu_timespec); + LOG(INFO) << "Elapsed CPU time: " + << (cpu_timespec.tv_sec + 1e-9 * cpu_timespec.tv_nsec) << " s"; +#endif + node.map_builder_bridge()->SerializeState(bag_filenames.front()); node.map_builder_bridge()->WriteAssets(bag_filenames.front()); }