|Image credit: https://www.flickr.com/photos/improveit/1987747052|
Some tips for program or software optimization:
1. Avoid the use of too many variables
If you can solve a problem with two variables, remove the third one that you’ve used in your program.
2. Divide your program into functions or sub-routines
When the same process has to be executed many times in a program, consider it to put in a function rather than writing the same procedure all over again. This would shorten the length of your source code. This is the main feature of top-down, structured programming.
3. Make a smaller function inline
Inline functions expand at the time of the function call itself. This reduces the cost of overheads such as jumping to the function, saving registers, pushing arguments into the stack and returning to the calling function. When a function is small, a substantial amount of time is spent in such overheads.