The C++ library has traditionally relied on stream classes for reading and parsing strings, but streams can be surprisingly slow. Some Node.js engineers, however, prefer stream classes for string building due to perceived performance benefits. To test this, an experiment was conducted replacing the ‘%’ character in strings with ‘%25’ using both traditional string construction and stream methods. The results showed that the stream version was four times slower than the traditional method and 30 times slower than an optimized ‘find’ approach. While results may vary depending on the system, this suggests that using streams in C++ may lead to poor performance.
https://lemire.me/blog/2023/10/19/for-processing-strings-streams-in-c-can-be-slow/