| MATLAB Function Reference | Search  Help Desk |
| profile | Examples See Also |
Start the M-file profiler, a utility for debugging and optimizing M-file code
Syntax
profile on
profile on -detail level
profile on -history
profile off
profile resume
profile clear
profile report
profile report basename
profile plot
profile status
stats = profile('info')
Description
The profiler utility helps you debug and optimize M-files by tracking their execution time. For each function, the profiler records information about execution time, number of calls, parent functions, child functions, code line hit count, and code line execution time.profile on
starts the profiler, clearing previously recorded profile statistics.
profile on -detail level
starts the profiler for the set of functions specified by level, clearing previously recorded profile statistics.| Value for level |
Functions Profiler Gathers Information About |
mmex |
M-functions, M-subfunctions, and MEX-functions; mmex is the default value |
builtin |
Same functions as for mmex plus built-in functions such as eig |
| operator |
Same functions as for builtin plus built-in operators such as + |
profile on -history
starts the profiler, clearing previously recorded profile statistics, and recording the exact sequence of function calls. The profiler records up to 10,000 function entry and exit events. For more than 10,000 events, the profiler continues to record other profile statistics, but not the sequence of calls.
profile off
suspends the profiler.
profile resume
restarts the profiler without clearing previously recorded statistics.
profile clear
clears the statistics recorded by the profiler.
profile report
suspends the profiler, generates a profile report in HTML format, and displays the report in your Web browser.
profile report basename
suspends the profiler, generates a profile report in HTML format, saves the report in the file basename in the current directory, and displays the report in your Web browser. Because the report consists of several files, do not provide an extension for basename.
profile plot
suspends the profiler and displays in a figure window a bar graph of the functions using the most execution time.
profile status
displays a structure containing the current profiler status. The structure's fields are shown below.| Field |
Values |
ProfilerStatus |
'on' or 'off' |
DetailLevel |
'mmex', 'builtin', or 'operator' |
HistoryTracking |
'on' or 'off' |
stats = profile('info')
suspends the profiler and displays a structure containing profiler results.Use this command to access the data generated by the profiler. The structure's fields areFunctionTable |
Array containing list of all functions called. |
FunctionHistory |
Array containing function call history. |
ClockPrecision |
Precision of profiler's time measurement. |
Remarks
To see an example of a profile report and profile plot, as well as to learn more about the results and how to use profiling, see Chapter 3 of Using MATLAB.Examples
Example
profile on -detail builtin -history
[t,y] = ode23('lotka',[0 2],[20;20]);
profile report
profile plot
profile resume
See Also
profreport