Add performance info to the offline node. (#420)
Outputs elapsed wall clock time and process CPU usage when the node finishes.master
parent
6f171dc5a7
commit
5417a4ab9d
|
@ -14,6 +14,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include <chrono>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -81,6 +83,8 @@ std::tuple<NodeOptions, TrajectoryOptions> LoadOptions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Run(const std::vector<string>& bag_filenames) {
|
void Run(const std::vector<string>& bag_filenames) {
|
||||||
|
const std::chrono::time_point<std::chrono::steady_clock> start_time =
|
||||||
|
std::chrono::steady_clock::now();
|
||||||
NodeOptions node_options;
|
NodeOptions node_options;
|
||||||
TrajectoryOptions trajectory_options;
|
TrajectoryOptions trajectory_options;
|
||||||
std::tie(node_options, trajectory_options) = LoadOptions();
|
std::tie(node_options, trajectory_options) = LoadOptions();
|
||||||
|
@ -260,6 +264,21 @@ void Run(const std::vector<string>& bag_filenames) {
|
||||||
node.map_builder_bridge()->FinishTrajectory(trajectory_id);
|
node.map_builder_bridge()->FinishTrajectory(trajectory_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::chrono::time_point<std::chrono::steady_clock> end_time =
|
||||||
|
std::chrono::steady_clock::now();
|
||||||
|
const double wall_clock_seconds =
|
||||||
|
std::chrono::duration_cast<std::chrono::duration<double>>(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()->SerializeState(bag_filenames.front());
|
||||||
node.map_builder_bridge()->WriteAssets(bag_filenames.front());
|
node.map_builder_bridge()->WriteAssets(bag_filenames.front());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue