Skip to content

Commit

Permalink
Add serialization time measurement
Browse files Browse the repository at this point in the history
  • Loading branch information
f0reachARR committed Oct 3, 2024
1 parent 8c62c00 commit b37034f
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ auto Interpreter::on_shutdown(const rclcpp_lifecycle::State &) -> Result

auto Interpreter::publishCurrentContext() const -> void
{
auto start = std::chrono::steady_clock::now();
Context context;
{
boost::json::monotonic_resource mr;
Expand All @@ -294,11 +295,21 @@ auto Interpreter::publishCurrentContext() const -> void
context.data = "";
} else {
context.data = boost::json::serialize(json << *script);
}
auto end = std::chrono::steady_clock::now();
RCLCPP_INFO_STREAM(
get_logger(),
"JSON serialization took "
<< std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() << " us");
}
context.time = evaluateSimulationTime();
}

publisher_of_context->publish(context);
auto end = std::chrono::steady_clock::now();
RCLCPP_INFO_STREAM(
get_logger(), "publishCurrentContext serialization took "
<< std::chrono::duration_cast<std::chrono::microseconds>(end - start).count()
<< " us");
}

auto Interpreter::reset() -> void
Expand Down

0 comments on commit b37034f

Please sign in to comment.