Questions on optimizing Mathematica code for higher performance. This may mean faster execution, lower memory usage or both. Not to be confused with mathematical optimization.
Questions on optimizing Mathematica code for higher performance. This may mean faster execution, lower memory usage, or both. Use mathematical-optimization instead for minimization/maximization of objective functions.
Optimization includes questions about how to make your code consume less memory/time and questions about how to query/assess consumption. The former includes the use of special data structures (like packed arrays, hash tables, dispatch tables), compiling, caching, compression, calling external programs, etc. The latter includes timing, profiling, etc.
For questions specific for compilation please also use the tag compile. For caching, use the tag caching. For questions on how to call or communicate with external programs, please use interoperability. Questions about how to debug code should use debugging.
Useful links:
- Time Measurement & Optimization Overview
- Memory Measurement & Optimization Overview
- Low Level System Optimization Overview
- Memory Management Tutorial
- Principles for Efficient Mathematica Programs, by Carl Woll, 2007, Wolfram Tech Conference
- Packed Arrays: An Efficient Internal Storage Format in Mathematica 4, by Rob Knapp
- Generally Efficient Numerics Programming in Mathematica, by Rob Knapp, 1999 Mathematica Developer Conference
- 10 Tips for Writing Fast Mathematica Code, by Jon McLoone, from the Wolfram Blog
- Performance tuning tips, by Leonid Shifrin
- Video tutorial on using the profiler from Wolfram Workbench
Example questions: