Main Content

Profile and Improve Performance

Find and remove bottlenecks in code

Write your code to be simple and readable, especially for the first implementation. Code that is prematurely optimized can be unnecessarily complex without providing a significant gain in performance. Then, if speed is an issue, you can measure how long your code takes to run and profile your code to identify bottlenecks. If necessary, you can take steps to improve performance.

Apps

ProfilerRun code and measure execution time to improve performance

Functions

ticStart stopwatch timer
tocRead elapsed time from stopwatch
cputimeCPU time used by MATLAB
timeitMeasure time required to run function
profileProfile execution time for functions
benchMATLAB benchmark

Topics