profile
Profile execution time for functions
Syntax
Description
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 Profiler.
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.
Examples
Input Arguments
Output Arguments
Limitations
The MATLAB Profiler performs calculations and collects data while the code is running. This requires additional computational resources and will result in code running slower with the Profiler active than identical code without. For this reason execution times measured by the Profiler should be treated as relative measures of code performance rather than absolute.
If the profiled code uses indirect (or mutual) recursion, the 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 theFunctionTable
entry.The Profiler is not supported when evaluating code sections.
Tips
To open the Profiler user interface, use the
profile viewer
syntax or see Profiler. 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.
Version History
Introduced before R2006a
See Also
Apps
Functions
Topics
- Profile Your Code to Improve Performance
- Profiling Parallel Code (Parallel Computing Toolbox)