Search code examples
c++ros

Is there any advantage in using rosfmt instead of ros stream print function?


I've seen the ROS wrapper for fmt library, called rosfmt, and was wondering if the performance is somehow better than using the ROS_WARN_STREAM(...) or similar functions


Solution

  • The exact answer to your question is what only direct profiling on the same system can give. In fact, it is expected that libfmt would beat printf system call because it implements complex output treatment, actually, a programming language, like awk does. As can be observable from the code, libfmt hardcodes many routines, so it can be faster than STL streams, but it depends totally on the current implementation. For ROS, avoidance of printf-based routines is definitely an advantage.