Jump to content

Does the code length matter in performance?

22 hours ago, ¨TrisT¨ said:

Hi.

Simple question

If I code a lot of stuff into one executable or project, I understand compiling will take longer.

But when running the program, if that code was never to be executed, would it make any difference performance wise?

Thank you.

 

22 hours ago, Nicholatian said:

Nope. It will run as fast as it can through everything. The flow of execution will take its path, and provided you’re not doing anything to slow it down, it will be fine. But the size of the executable doesn’t inherently make it slower. ?

 

19 hours ago, fizzlesticks said:

If you have enough extra code and you jump around a lot, the extra code could cause instruction cache misses that would greatly decrease performance.

^Listen to this man. It's actually one reason Intel's compiler is shit when templates outside the STL algorithms get involved.

 

But, first I need to know what language you're talking about. Natively compiled languages (C/C++, Fortran, Objective C, Swift) are susceptible to compiler optimization mistakes. Interpretted/Virtually Compiled languages (Python and Java respectively) definitely take performance hits the longer your code is, because the virtual instruction cache is only so large, and code is constantly being recompiled at runtime if that cache fills up, so if your code isn't small, you take it on the chin without a doubt.

 

Side note: this is also why Java class, jar, and war files seem to be so small compared to executables generated by C/C++. They expand at runtime through byte code-machine code translation. C/C++ give you the whole program in machine code exactly once.

Software Engineer for Suncorp (Australia), Computer Tech Enthusiast, Miami University Graduate, Nerd

Link to post
Share on other sites

2 hours ago, Nicholatian said:

Yeah, this is the right answer here. I don’t suppose it’s all that important, though? How apparent would such things be in a desktop environment? I didn’t think cache could complicate things so much, lol.

on a modern desktop probably not at all. Python, for example, is actually a pretty slow language yet you don't see the internet being full of "python is too slow".

 

in mission critical systems where there is lots of activity it will matter more.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×