Programming and Data Types    

The profile Function

The Profiler is based on the results returned by the profile function. There are some features available with the profile function that are not part of the Profiler.

To use the profile function:

  1. Type profile on in the Command Window. Specify any options you want to use.
  2. Execute your M-file.
  1. The profile function counts how many seconds each line in the M-files uses. It works cumulatively, that is, adding to the count for each M-file you execute until you clear the statistics.

  1. Use profile report to display the statistics gathered in an HTML-formatted report in your system's default Web browser. This report contains some information different from what is available in the Profiler reports.

Here is a summary of the main forms of profile. For details about these and other options, type doc profile.

Syntax
Option
Description 
profile on

Starts profile, clearing previously recorded statistics.

-detail level
Specifies the level of function to be profiled.

-history
Specifies that the exact sequence of function calls is to be recorded.
profile off

Suspends profile.
profile report

Suspends profile, generates a profile report in HTML format, and displays the report in your system's default Web browser. This report contains some information different from what is available in the Profiler reports.

basename
Saves the report in the file basename in the current directory.
profile plot

Suspends profile and displays in a figure window a bar graph of the functions using the most execution time.
profile resume

Restarts profile without clearing previously recorded statistics.
profile clear

Clears the statistics recorded by profile.
profile viewer

Opens the Profiler, a graphical user interface. This provides information gathered using the profile function, but presents the information in a different format from the profile function reports.
s = profile('status')

Displays a structure containing the current profile status.
stats = profile('info')

Suspends profile and displays a structure containing profile results.

Some people use profile simply to see the child functions; see also depfun for that purpose.


  Changing Fonts for the Profiler An Example Using profile