[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

brainlet here,why does "endl" makes my program run

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 15
Thread images: 6

File: Screenshot (70).png (130KB, 1366x768px) Image search: [Google]
Screenshot (70).png
130KB, 1366x768px
brainlet here,why does "endl" makes my program run 7 times slower?is the gcc's implementation of endl is badly written?

posting other pics in a sec for comparison.
>>
File: Screenshot (71).png (135KB, 1366x768px) Image search: [Google]
Screenshot (71).png
135KB, 1366x768px
here is the code with line-breaking.i was expecting it to be slower because of the line breaks but 7 times slower?
>>
try using a '\n' in the string instead of leaving it out. gotta get scientific on this bitch
>>
because endl also forces a output stream flush. you should always use "\n" for line breaks and endl when you need to force flush
>>
File: Screenshot (72).png (135KB, 1366x768px) Image search: [Google]
Screenshot (72).png
135KB, 1366x768px
>>60692601
yeah \n is faster though still 5 times slower.
>>
File: 1484976788035.jpg (265KB, 1920x1200px) Image search: [Google]
1484976788035.jpg
265KB, 1920x1200px
>>60692605
>>60692601
OP post above two result. I am curious
>>
File: Screenshot (75).png (141KB, 1366x768px) Image search: [Google]
Screenshot (75).png
141KB, 1366x768px
OMGOMGOMG GUYS I FOUND SOMETHING.unwrapping the loop makes it insanely fast.gcc shit with loops confirmed?
>>
>>60692718
It runt 1000 times instead of 10000 now, right?
>>
>>60692814
no,it ran 10 000 times just like the others.there's a line counter on the left of the ide.
>>
>>60692530
>brainlet here,why does "endl" makes my program run 7 times slower?
No, because stdout is flushed on newline, while without any newline it is flushed on program exit.


>>60692661
>>60692601
See above
>>
>>60692842
lol i just realized the line counter is fucked.it starts from 1 again after 1023 wtf
>>
>>60692842
line counter returns at line 1010 though
loop unrolling does yield better performance but not this much
>>
in windows use putchar_unlocked or something, or just write to handle directly and force int
>>
>>60692718
shouldn't it be repetitions of
cout << "hello world!\n";
i++;
if( !( i < 10000 ) ) break;

instead of just the cout?
>>
File: 1491409713700.png (937KB, 776x795px) Image search: [Google]
1491409713700.png
937KB, 776x795px
>>60692718
try compiling the original code with -funroll-loops

>tfw the gentoo meme is real
Thread posts: 15
Thread images: 6


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.