| MATLAB Function Reference | ![]() |
Tool for optimizing and debugging M-file code
Graphical Interface
As an alternative to the profile function, select View -> Profiler from the desktop.
Syntax
profileviewerprofileonprofileon -detaillevelprofileon -historyprofileoffprofileresumeprofileclearprofilereportprofilereportbasename profileplots = profile('status') stats = profile('info')
Description
The profile function helps you debug and optimize M-files by tracking their execution time. For each function in the M-file, profile records information about execution time, number of calls, parent functions, child functions, code line hit count, and code line execution time. Some people use profile simply to see the child functions; see also depfun for that purpose. The Profiler user interface, opened with profile viewer, provides information gathered using the profile function, but presents the information in a different format from profile report.
profile opens the Profiler graphical interface, a tool for assessing M-file performance to help you identify potential performance improvements. It is based on the results returned by the viewer
profile function, but presents the information a different format than the profile report. The report function provides some options not available with the Profiler, including saving the reports to a file.
profile starts on
profile, clearing previously recorded profile statistics.
profile starts on -detail level
profile for the set of functions specified by level, clearing previously recorded profile statistics.
| Value for level |
Functions profile 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 starts on -history
profile, clearing previously recorded profile statistics, and recording the exact sequence of function calls. The profile function records up to 10,000 function entry and exit events. For more than 10,000 events, profile continues to record other profile statistics, but not the sequence of calls.
profile restarts resume
profile without clearing previously recorded statistics.
profile clears the statistics recorded by clear
profile.
profile suspends report
profile, generates a profile report in HTML format, and displays the report in your system's default Web browser. This report contains some different information than what is available in the Profiler reports.
profile suspends report basename
profile, generates a profile report in HTML format, saves the report in the file basename in the current directory, and displays the report in your system's default Web browser. Because the report consists of several files, do not provide an extension for basename.
profile suspends plot
profile and displays in a figure window a bar graph of the functions using the most execution time.
s = profile( displays a structure containing the current 'status')
profile status. The structure's fields are
| Field |
Values |
ProfilerStatus |
'on' or 'off' |
DetailLevel |
'mmex', 'builtin', or 'operator' |
HistoryTracking |
'on' or 'off' |
stats = profile(' suspends info')
profile and displays a structure containing profile results. Use this function to access the data generated by profile. The structure's fields are
| Field |
Description |
FunctionTable |
Array containing list of all functions called |
FunctionHistory |
Array containing function call history |
ClockPrecision |
Precision of profile'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 Measuring Performance" and "The profile Function" in MATLAB Programming documentation.
Examples
Follow these steps to run profile and create a profile report.
See Also
depdir, depfun, profreport, tic
See "Measuring Performance, The Profiler, and The profile Function in the MATLAB Programming documentation.
| prod | profreport | ![]() |