|
Hey guys just wanting to get some info about some small things that may or may not be impacting performances for a game. First off i was wondering it it was more effective to call functions to execute code than to just put the code in the the update function. Pesudo* Code example
as opposed to
Also i was wondering if and when a class is too large, example a class with over 600 lines of code, would it be more effiecient to split it into 2 300 line scripts or is it just personal preference, also any general tips for c# programming optimization will be greatly appreciated =D
(comments are locked)
|
|
Get your code working first, then optimize later if needed. Make code as simple and readable as possible, in order to lessen the chance of bugs. Have as little code running as possible. Profiler is a great tool here. I usually detect the performance problems when the garbage collector is executed. If it gets launched too many times per second, then there's something I can optimize, typically regarding passing structs as value or creating too many disposable classes on each cycle.
Aug 29 '10 at 09:41 AM
Edy
(comments are locked)
|
|
Compilers are quite smart nowdays, even runtime ones. Less important than how you organise is basically not wasting cpu cycles on things that aren't necessary (doing things too often) and allocating memory on the fly (dynamically calling variables rather than using existing ones). In response to SpikeX, there's nothing wrong with knowing how the underlying tech of what you're doing works. Only with better understanding of how things work can you improve upon what you make :)
(comments are locked)
|
|
None of these issues that you're mentioning are going to affect your gameplay in any way whatsoever. It doesn't matter if you have one class or two, or if you split functions into multiple parts. The difference in performance probably isn't even measurable. Why are you even worrying about these mundane details in the first place? im fairly new to programming so i was just wondering if i was doing things the right way because ive seen alot of code split into many functions and hardly anything in the main functions IE Update, so i was just curious if this was a personal preference or for performance optimization
Aug 10 '10 at 02:43 AM
unityprogrammer008
It's preference. Like Eric said, get your code running first, and then fix it later.
Aug 10 '10 at 05:27 AM
qJake
(comments are locked)
|
