Oh good lord. This question is more about properly isolating your tests (i.e. writing the characters to /dev/null and getting rid of the "random" call) and properly profiling code (which would show high CPU consumption on the console, not the program writing to stdout) more than anything "tricky" about performance.
Never assume something is common knowledge! I've seen many links to mathematics things here on HN that I would consider "common knowledge" yet many people were unaware of them.
I remember minimizing the terminal window to make a script run faster. Taking the text rendering out of the execution path actually had a substantial speedup for long running scripts in some cases. It was one of those things you sort of picked up from other people along the way and assumed everyone knew.
Nowadays I don't know if the difference is noticeable enough to be common knowledge though.