MATLAB Function Reference | ![]() ![]() |
Start the M-file profiler, a utility for debugging and optimizing M-file code
Syntax
profileon
profileon -detail
level
profileon -history
profileoff
profileresume
profileclear
profilereport
profilereport
basename profileplot
s = profile('status
') stats = profile('info
')
Description
The profiler utility helps you debug and optimize M-files by tracking their execution time. For each function in the M-file, the profiler records information about execution time, number of calls, parent functions, child functions, code line hit count, and code line execution time.
profile
starts the profiler, clearing previously recorded profile statistics.on
profile
starts the profiler for the set of functions specified by on
-detail
level
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
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. on -history
profile
suspends the profiler.off
profile
restarts the profiler without clearing previously recorded statistics.resume
profile
clears the statistics recorded by the profiler.clear
profile
suspends the profiler, generates a profile report in HTML format, and displays the report in the Help browser.report
profile
suspends the profiler, generates a profile report in HTML format, saves the report in the file report
basename
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 the profiler and displays in a figure window a bar graph of the functions using the most execution time.plot
s = profile(
displays a structure containing the current profiler status. The structure's fields are shown below.'status
')
Field |
Values |
ProfilerStatus |
'on' or 'off' |
DetailLevel |
'mmex' , 'builtin' , or 'operator' |
HistoryTracking |
'on' or 'off' |
stats = profile('
suspends the profiler and displays a structure containing profiler results. Use this function to access the data generated by the profiler. The structure's fields areinfo
')
FunctionTable |
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 Improving M-File Performance: the Profiler.
Example
profile on -detail builtin -history [t,y] = ode23('lotka',[0 2],[20;20]); profile report
The profile report appears in your system's default Web browser, providing information for all M-functions, M-subfunctions, MEX-functions, and built-in functions. The report includes the function call history.
profile resume
See Also
Improving M-File Performance - the Profiler" in Using MATLAB
![]() | prod | profreport | ![]() |