You are totally correct about this - the only real performance booster for IO bound operations is buffering, which delays the writes to be less frequent or follow a clock.
I wrote a logging library that used channels, and it was pointed out to me that this doesn't have a big effect. But I think it *should* allow a multi-core system to keep one or a few cores dedicated to the CPU bound processing part of the work, and the IO, with all its waiting, to other threads/cores. So, using WriteString would make sense, if the Writer it addresses is buffered, if performance is needing to be squeezed just a little more. But the buffer matters far more. On Friday, 3 May 2019 16:54:37 UTC+2, Robert Engels wrote: > > I suggest that it might benefit you to understand cost of IO. In most > systems the IO cost dwarfs the CPU cost of optimizations like these. I am > not saying it never matters - I have significant HFT experience and sone > HPC - but in MOST cases it holds true. > > So micro optimizing the CPU usually has little effect on total runtime. > > Broken algs, ON^2, are another story. > > On May 3, 2019, at 9:38 AM, Louki Sumirniy <louki.sumi...@gmail.com > <javascript:>> wrote: > > There is a big difference between the parameters of these two functions. > One is a slice of interface, the other is only a a single string parameter. > fmt print functions all have nasty messy interface switching and reflection > internally hence the significant overhead. > > A lot of people clearly don't know this, also - there is a builtin print() > and println() function in Go. If the output is stdout, these are probably > the most efficient ways to thow strings at it. Clearly the same goes for > io.WriteString, but with the option of using another Writer instead of > stdout. > > On Monday, 22 April 2019 03:13:22 UTC+2, codi...@gmail.com wrote: >> >> Hi gophers! Just wondering if in a Handler I should (w is the >> http.ResponseWriter): >> >> fmt.Fprint(w, "Hello world") >> >> or is it better to >> >> io.WriteString(w, "Hello world") >> >> or is it the same if fmt.Fprint already uses WriteString internally? >> > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golan...@googlegroups.com <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.