ROS performance testing: C++ vs Python

ROS supports both Python and C++ programming languages, however, using Python can come at a performance cost. I did an experiment to test this by writing four combinations of publisher to subscriber and then checking whether the real loop rate (of the publisher) is equal to the actual loop rate of the subscriber. The combinations tested, and points of deviation of desired and true frequency rates are:

  • C++ publisher to Python subscriber (combination 1) – 10000Hz
  • C++ publisher to C++ subscriber (combination 2) – 2000Hz
  • Python publisher to Python subscriber (combination 3) – 1000Hz
  • Python publisher to C++ subscriber (combination 4) – 800Hz

The results are shown in the graph below, which confirms that C++ is faster than Python for ROS.  The code for this test is available in the FunWithROS Github repository.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s