Profile execution time for functions
Use the Profiler to track execution time. Knowing the execution time of your MATLAB® code helps you to debug and optimize it. For information on the user interface to the Profiler, see Profile Your Code to Improve Performance.
profile
profiles
the execution time for functions. Use action
action
to
start, stop, and restart the Profiler, and view or clear profile statistics.
For example, profile on
starts the Profiler.
profile
starts or restarts the Profiler
with the specified options. For example, action
option1
... optionN
profile resume -history
restarts
the Profiler and records the sequence of function calls.
profile
sets
the specified Profiler options. If the Profiler is on and you specify
one of the options, MATLAB throws an error. To change options,
first specify option1 ... optionN
profile off
, and then specify the
new options.
If the profiled code uses indirect (or mutual) recursion, the MATLAB Profiler might return inaccurate results. If the recursion is direct (a single function calling itself), then the Profiler returns the total time for the non-recursive calls to the function. To determine if a function in the profiled code is recursive (directly or indirectly), examine the value of the IsRecursive
field in the FunctionTable
entry.
To open the Profiler user interface, use the profile viewer
syntax or see Profile Your Code to Improve Performance. The Profiler user interface is not
supported in MATLAB
Online.
As of MATLAB R2015b, the default timer is 'performance'
.
In previous versions of MATLAB, the default profiler timer was 'cpu'
,
which measures compute time instead of wall-clock time.
checkcode
| matlab.codetools.requiredFilesAndProducts
| profsave