3 ms·
You should time it and come back. You're wrong.
by CoolGuySteve 6y ago
You should time it and come back. You're wrong.
- nkurz 6y agoYou might be right, but your response comes across as rather rude. I think you should either soften your message, or provide more details about the timing --- or both! My instinct is that for standard IO involving moderate amounts of string interpolation and number formatting in C running on Linux on modern Intel processors, klodolph is probably closer to right. But maybe you are right for some other setup? Or maybe klodolph and I are both wrong, in which case some more details would be helpful.
- CoolGuySteve 6y agoI gave a time in my original post: 1-2usec. Printing a handful of doubles with a cold instruction cache using the standard stdio headers takes longer than that due to all the special casing. klodolph made some handwavey claim about synchronization overhead that are clearly false. It doesn't even make sense to me since the device being printed to will need some sort of synchronization and syscall. Both you and klodlph are also making handwavey claims about formatting speed in Linux. You both need to measure before you argue. I find it extremely rude to argue from a position of ignorance as both of you are doing. "Well gee, I dunno but you're probably wrong". It's so asinine.
- klodolph 6y agoSure, if you have a cold instruction cache. If stdio is not in your instruction cache, or at least in L2, then you’re not using it very much, and you won’t get much benefit from moving it to a different thread. My measurements put stdio formatting at around 100ns for the typical messages I’m printing. So, offloading it to another thread is a fairly clear loss. Even for floating point numbers, you’ll hit the fast path with fairly high regularity. My measurements put it at around 80ns for a double, on my system, most of the time.