Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
fabriceleal
· 8y ago · 0 comments
Probably more about the difference between "echo" and "std::cout << ... << std::endl;" than the recursive function call.
Comments
[–]
Sean1708
8y ago
I would be
very very
surprised if printing "2971215073" accounted for more than 1 second of runtime.
[–]
gambler
8y ago
Well, I know that printing stuff to console can be ridiculously slow, so this doesn't surprise me much.
[–]
Sean1708
8y ago
An entire second to print 10 characters?! How does a terminal that slow even exist?
[–]
VeXocide
8y ago
std::endl flushes which isn't cheap, you're generally better off simply steaming in a newline.
[–]
lucozade
8y ago
Most of it won't be because the C++ constexpr version has the same IO call and runs in <0.1s.
[–]
syockit
8y ago
I think that's because even the std::cout call could be precalculated, so no runtime string concatenation and stream magic is involved.