0

I am building a ROS2 GUI. In this there is a function:

rclpy.spin_once(qt_node, timeout_sec=0)

This processes every ROS2 message that has been received since it was last called. If no messages have been received, it waits for timeout_sec and returns. It is called every iteration of the QML GUI loop. I want to know how much time this function is taking to deduce if it is worth moving to a separate thread from the QML GUI (which adds a lot of complexity because of how data is shared/converted between my python code and qml code).

I have tried timing it with:

profiler.runcall(rclpy.spin_once, qt_node, timeout_sec=0)

But the stats profiler.dump_stats("profiler.prof") when viewed with SnakeViz only shows the, ncalls, tottime, percall, cumtime, and percall. This is useless as most of the time spin_once takes 0 seconds (because most of the time there are no messages), and then other times lots of messages come in at once. How can I view the maximum time spin_once has taken? Or even better, view it in a histogram.

Blue7
  • 1,750
  • 4
  • 31
  • 55

0 Answers0