Before you take steps to improve code generation, read about your options in Optimization Strategies.
coder.inline |
Control inlining in generated code |
coder.const |
Fold expressions into constants in generated code |
coder.ceval |
Call external C/C++ function |
coder.Constant |
Represent set containing one MATLAB value |
coder.CodeConfig |
codegen configuration object |
coder.ExternalDependency |
Interface to external code |
Prevent Code Generation for Unused Execution Paths
Make a control-flow variable constant to prevent code generation of unused branches.
Eliminate Redundant Copies of Function Inputs
Use the same variable as a function input and output.
Inlining eliminates the overhead of a function call by replacing the function call with the body of the function.
Restrict inlining to reduce the size of generated code and memory usage.
Specify the maximum stack space that the generated code can use.
Fold Function Calls into Constants
Reduce execution time by replacing expression with constant in the generated code.
Set Dynamic Memory Allocation Threshold
Disable dynamic memory allocation for arrays less than a certain size.
Reuse Large Arrays and Structures
Specify variable reuse to reduce memory usage.
Disable Support for Integer Overflow or Non-Finites
Improve performance by suppressing generation of supporting code for integer overflow or non-finites.
Integrate External/Custom Code
Improve performance by integrating your own optimized code.
Optimize the execution speed or memory usage of generated code.
Excluding Unused Paths from Generated Code
Make the control-flow variable constant to prevent generation of code for unused branches.
Stack Allocation and Performance
Allocate large variables on the heap when you have limited stack space.
MATLAB Coder Optimizations in Generated Code
To improve the performance of generated code, the code generator uses optimizations.
Disable Support for Integer Overflow or Non-Finites
Improve performance by suppressing generation of supporting code for integer overflow or non-finites.