Necrobumping for importance!
More tips should be added, this should be something like a sticky.
On that last thing that was said so many years ago..
Every mathmatical calculation that has to be done in the in code is what increases the size of the executable itself. For every time it has to add, subtract, multiply, or divide.
Meaning:
- Code: Select all
while( x != 100) { ++x;)
is more resource friendly than
- Code: Select all
x = x +1;
x = x +1;
x = x +1;
x = x +1;
x = x +1;
x = x +1;
x = x +1;
x = x +1;
x = x +1;
x = x +1;
x = x +1;
x = x +1;
x = x +1;
//ect 100 times..
Because the first one just puts this function in the machine code:
ADD 1 -> X;
Jump back one space in memory until X = 100;
while the second actually adds that one ADD line, one hundered times into the memory.
So as it was said, the more automation is better, not only does it save YOU time, but it saves valuable resources too.
Sometimes what may seem like sufficient code is really taxing on the cpu because it has to repeat the same task multiple times even though it could have just jumped back to a line in the memory and started there again rather then streaming through and reloading its cache.
Remember that your program goes through this process:
CPU->Cache->CPU->North Bridge->Ram->North Bridge->CPU->Cache->CPU->Cache->CPU->Cache->CPU->North Bridge->Ram->North Bridge->CPU->Cache->CPU->North Bridge->South Bridge->internal components->External Components
Sometimes repeating its path back and forth from the CPU to RAM thousands of times, sometimes even heading to the Hard Drive to be stored in the page file then be picked back up into the RAM.
So the more equations your program makes the more work your cpu does.