- Home /
Does big code affect performance
if you have say 10 scripts and they are all more than 3k of lines, it makes unity compile slower than it was with only 1 script, but does it also affect the game or no?
Answer by tanoshimi · Nov 25, 2013 at 07:33 AM
There is very little correlation between the number of lines of code and the length of time taken to execute an application.
For starters, some of that code may never get executed, in which case it has zero effect on the game performance. Secondly, two single "lines" of code may have immensely different complexity from each other, depending on what they're actually trying to achieve. Remember that your C#/Javascript/Boo code will be compiled before it is executed, so the computer does not see the same 30,000 lines of code that you're looking at - it will see some amount of instructions in compiled bytecode. A CPU can run billions of instructions every second, so if every line of your code translates to a single instruction, and does so efficiently, your computer will zip through 30,000 lines of code in a fraction of a microsecond. But if just one of those lines sets up an infinite recursive loop, it'll take forever, however fast your computer is.
Worry about code quality, not code quantity.
Your answer
![](https://koobas.hobune.stream/wayback/20220613122659im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity Code Performance Issue 1 Answer
Which to use Arrays, Collections, Lists and Generics 0 Answers
Script Efficiency 1 Answer
Improving code performance 1 Answer