↓ Skip to main content

“In particular, it’s faster than memcpy, which presents interesting challenges when it comes to I/O (if you try to output using write then the copies in write will take up almost all the runtime – replacing the I/O routine here with write causes the performance on my CPU to drop by a factor of 5).”

ais523codegolf.stackexchange.com ↗

A FizzBuzz that outruns memcpy. It keeps the output in L2 cache and splices it into the pipe so the data barely touches main memory. The bottleneck is the write speed of the cache itself. Interviewers ask FizzBuzz to see if you can code at all. This answer shows how far from the hardware most code really runs.