Summary
This episode explains why using std::endl for line breaks in C++ stream operations can significantly impact performance. Jason demonstrates that std::endl is equivalent to outputting a newline character ('\n') followed by a flush operation, which forces the OS to write buffered data to disk immediately. Through benchmarking, he shows that using std::endl can be up to 17 times slower than using simple newline characters when writing to files, as each flush operation interrupts the normal buffering behavior of streams.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[ostream]40% match