|| at Aug 8, 2013 at 12:50 am
On Wednesday, August 7, 2013 4:47:15 PM UTC-7, Tony Worm wrote:
calls to printf and scanf involve asking the operating system to do
something on your behalf as I recall. I don't see how Go could do it
I haven't looked at the implementation of Printf, but there's usually
buffering in between. It's entirely possible that Printf buffers the entire
output in memory and then makes one Write call. Or maybe it buffers in 32k
chunks or something. And at a higher level, the output streams might buffer
in memory before writing to the OS's streams.
I'd guess there is some buffering going on somewhere,
but I recall it being faster to build large strings in memory
and then print that out with one call to printf
I think you're over-optimizing. Do it in a way that makes sense to you,
then if it's too slow you can profile it and find out where the bottlenecks
are. As David said, formatted IO is pretty CPU-intensive to begin with.