Date: Mon, 31 Jan 2022 19:37:34 -0800
On Sunday, 30 January 2022 12:41:02 PST Dimitrij Mijoski via SG16 wrote:
> void bm_printf_with_string(benchmark::State& s) {
> while (s.KeepRunning())
> std::printf("The answer is 42.\n");
> }
You should check if GCC didn't replace the printf with no extra parameters and
ending in \n with puts. It usually does that.
> > 2. Better performance. iostreams have an inherent interoperability /
> > performance tradeoff which is why we have sync_with_stdio in the
> > first place. It applies to both formatted and unformatted output.
>
> As you can see above, at least on Linux, C++ iostreams are faster than
> C streams.
You disabled the sync. No one does that. So the benchmark is not realistic.
> Well this is a drawback that exists since iostreams were invented, it
> is there. std::print won't solve it. All users of cout already have it.
> If one wants to solve it one has to invent new IO facilities.
Which is a reason not to tie std::print to it, because then we are able to add
a new implementation without bringing the iostreams baggage.
> void bm_printf_with_string(benchmark::State& s) {
> while (s.KeepRunning())
> std::printf("The answer is 42.\n");
> }
You should check if GCC didn't replace the printf with no extra parameters and
ending in \n with puts. It usually does that.
> > 2. Better performance. iostreams have an inherent interoperability /
> > performance tradeoff which is why we have sync_with_stdio in the
> > first place. It applies to both formatted and unformatted output.
>
> As you can see above, at least on Linux, C++ iostreams are faster than
> C streams.
You disabled the sync. No one does that. So the benchmark is not realistic.
> Well this is a drawback that exists since iostreams were invented, it
> is there. std::print won't solve it. All users of cout already have it.
> If one wants to solve it one has to invent new IO facilities.
Which is a reason not to tie std::print to it, because then we are able to add
a new implementation without bringing the iostreams baggage.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DPG Cloud Engineering
Received on 2022-02-01 03:37:36