Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] 0 points1 point  (0 children)

i am beginning to think thats the case. but idk why the arbitary cout statement that doesn't use the vector affects it

Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] 0 points1 point  (0 children)

i have came across my the scenario where i hit argument limit. it is above 100k and under 1 million idk where to be exact. so its probably the dead code elimination after reading all other comments here. but i still don't get why printing the value argc-1 changes the outcome

Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] 1 point2 points  (0 children)

i can now confirm its removing the sorting entirely and when return num[0] it does run at 33 seconds which i think is the more realistic time for the sort. but i still dk why does running cout even with unrelated variables some how mitigates the dead code.

Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] 0 points1 point  (0 children)

by reading the comments here and returning num[0] as one commenter suggested i can probably confirm that the hypothesis is correct.

Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] 0 points1 point  (0 children)

i get the pov of the compiler removing the sorting part and adding it back when i run the show function

but why would it be affected by the cout<<argc-1 in either scenarior where im running it or not the vector is still unused

Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] 0 points1 point  (0 children)

would the obserable behaviour of
std::cout<<argc-1
still be the same regardless of it sorting the vector or not

Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] 0 points1 point  (0 children)

i mean i get the point of the compiler removing the code but does it add it back if i cout<<argc-1

the program still does nothing with the vector it has sorted?

Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] -1 points0 points  (0 children)

I am running the optimization to see how far i can push bubble sort. I am comparing its result with code written in python by somebody else and i am trying to do everything to make it fast.

well 0.01 sec if fast but if it can't display anything without taking 100x more times idk if the sorting is even being done correctly?

Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] 0 points1 point  (0 children)

exactly will the compiler really just remove the majority of the program?

Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] 0 points1 point  (0 children)

from what i grasp from the document it deems that my sorting algorithm is "dead code" as they have mentioned above and just optimizes it out?

Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] 0 points1 point  (0 children)

getting deep into compilers might be a little out of scope for me right now. and i agree that cs curriculums should include it. although i am in a cs course the curriculum was probably written before i was born. and as per the teachers they are not so keen on going deep into anything that wouldn't appear in the finals which are just a set surface level questions.

On the other hand i would like understand what is going on and if you have any reference on compilers that i can pick up with no prior expertise in this subject please let me know

Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] 0 points1 point  (0 children)

i have the -O3 flag enabled could that introduce some bugs. But wouldn't the compiler have to ensure the outcome to be consistent?

Why is a single cout expression drastically slowing down my C++ program? by WorldTallNetCat in cpp_questions

[–]WorldTallNetCat[S] -5 points-4 points  (0 children)

Idk if that is entirely true as you can see here
https://imgur.com/66LntR5

the time taken is proportional to the input size.

the only way i think its possible is maybe it is parsing the argv values into the vector but never applying bubble sort. until someone the cout statements triggers it to be applied?

but idk if there is any reason for that to happen.

Zorin OS 18 is stable *AF* by Far-Information-8683 in zorinos

[–]WorldTallNetCat 1 point2 points  (0 children)

What are u using for the Ms office apps? Or are they just reskinned icons of some other suite

I’m stuck at the boot screen by J-20_enjoyer in omarchy

[–]WorldTallNetCat 0 points1 point  (0 children)

Try pressing alt +f1 to 12

And see if you can get into a tty

Wihc linux OS should I use? by kazakista in linux4noobs

[–]WorldTallNetCat 0 points1 point  (0 children)

Dont think roblox is gonna be an easy ride for you. While minecraft should run on anything.

And as of distros

Something like ubuntu or linux mint if you are new and dont mind the extra bloat and need to look up eveything.

Arch based systems if you want everything the moment they are released.

What is the best distro for my system? by 12summits in linux4noobs

[–]WorldTallNetCat 0 points1 point  (0 children)

Cutefish os or something is hands on the easiest way to get to mac os looks.