C++ does printing to terminal significantly slow down code?
c++, performance, printing, terminal
Solution
Yes, rendering to screen takes longer than writing to file. In windows its even slower as the program rendering is not the program that is running, so there are constantly messages sent between processes to get it drawn. I guess its same in linux since virtual terminal is on a different process than the one that is running.
Problem
I have a code where I currently print a lot of diagnostic messages to terminal. Does anybody have any idea how much this slows down my code? Would I get a big speed increase by piping the output to file, e.g. instead of running: ``` ./my_program ``` i run ``` ./my_program > output.log ``` Also, would I get a further speed increase by replacing cout with ofstream and writing to file directly? EDIT: Let's assume I am writing to /dev/shm, disk access speed not really an issue.