Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
![](/static/devrant/img/pipeless-devrant-banner-white.png)
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
CodeBlocks and light theme...
Please do yourself a favour and use Visual Studio, CLion, or any of the more sophisticated editors (VSC, etc.)
Also, no kidding. To print it has to trap into the OS and fiddle with graphics. Very expensive operation. -
Yeah, do the exact same code without the actual printing and it'll take an infinitesimally smaller amount of time to run.
-
@RememberMe I use Visual Studio, dark theme. I have to use CodeBlocks because tomorrow I participate to a contest that uses CodeBlocks and I must get used with it.
I'll repeat the test with no print. -
@dandrei279 Ah, I see.
Also, here's some interesting stuff about C++ I/O:
http://drdobbs.com/the-standard-lib...
Also, if you're using endl I *think* it flushes the stream, try with "\n" instead. And maybe write to a buffer and print the buffer in large chunks? (Though I/O should buffer anyway, not sure if this would increase performance). -
b3b343787yYou could generate a huge string and only print it once. Then you wouldn't have that print calls and it'd be faster I think. Should test it...
@martikyan ew. Pls stop -
olback109937yA solution to the slow printing, store your output in a large buffer and when it's getting close to being full, print it and empty it. Repeat.
-
olback109937yprintf() is super slow, I think cout would be faster since it's a stream, could be super wrong though.
-
gitlog62066y@olback you are super wrong....
Printf is faster than cout
If you are in competitive coding especially, you must know this -
gitlog62066y@faheel but there was this one question I did an year back, where it didn't go as expected...
Even using sync_with_stdio(false) make it TLE but scanf and printf made it.
Tbh one shouldn't devise such test cases and constrains
Related Rants
-
xjose97x19Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...
-
sam966911
Hats off to this lady .... I would have just flipped the machine
That long took to display "Ave user!" 32,000,000 times
rant
c++