This is suited for functional programming.
Blind optimizations: just say NO.
1. Write some unit tests that ensure your code stays correct.
2. DO NOT ASSUME ANY KNOWLEDGE ON WHAT SHOULD BE OPTIMIZED- but try to "see"
possible bottlenecks.
3. Write a the smallest possible program that uses the code to optimize, such that
the program exhibits the functionality that seems to be the bottleneck(s).
Design this program to run for a few seconds without user interaction.
4. Use a decent profiler to profile a complete run of this program
5. Optimize the bad code in this order
- estimate the complexity of the code around hotspots
- try diffrent data structures and algorithms
- try to involve background knowledge
- try to combine several functions into one
- records should fit into the cache of the target platform
- add more strictness(dangerous)
- move common subexpressions or constant subexpressions to a higher scope(generalisation of precalculation)
- use more efficient primitives(do I really need an arbitrary precission floating point)
Following the steps from above I was able to optimize two new programms each by a factor of about 50(!).
Blind optimizations: just say NO.
1. Write some unit tests that ensure your code stays correct.
2. DO NOT ASSUME ANY KNOWLEDGE ON WHAT SHOULD BE OPTIMIZED- but try to "see"
possible bottlenecks.
3. Write a the smallest possible program that uses the code to optimize, such that
the program exhibits the functionality that seems to be the bottleneck(s).
Design this program to run for a few seconds without user interaction.
4. Use a decent profiler to profile a complete run of this program
5. Optimize the bad code in this order
- estimate the complexity of the code around hotspots
- try diffrent data structures and algorithms
- try to involve background knowledge
- try to combine several functions into one
- records should fit into the cache of the target platform
- add more strictness(dangerous)
- move common subexpressions or constant subexpressions to a higher scope(generalisation of precalculation)
- use more efficient primitives(do I really need an arbitrary precission floating point)
Following the steps from above I was able to optimize two new programms each by a factor of about 50(!).
Comments