Desktop Tools and Development Environment Previous page   Next Page

Running the Profiler

The following illustration summarizes the steps for profiling.

Image of Profiler showing steps to run it. 1, Type provide viewer to open the Profiler. 2, Type the statement to run in the Run this code field of the Profiler. 3, click the Start Profiling button.

To profile an M-file or a line of code, follow these steps:

  1. In the Run this code field in the Profiler, type the statement you want to run.
  1. You can run this example

    as the code is provided with MATLAB demos. It runs the Lotka-Volterra predator-prey population model. For more information about this model, type lotkademo, which runs the demonstration.

    To run a statement you previously profiled in the current MATLAB session, select the statement from the list box--MATLAB automatically starts profiling the code, so skip to step 3.

  1. Click Start Profiling (or press Enter after typing the statement).
  1. While the Profiler is running, the Profile time indicator (at the top right of the Profiler window) is green and the number of seconds it reports increases.

    Image of Profile time indicator, colored green to indicate that the Profiler is running, and showing the profile time currently as 4 seconds.

    When the profiling is finished, the Profile time indicator becomes black and shows the length of time the Profiler ran.

    Image of Profile time indicator, colored black indicating that profiling has stopped, and showing the total time of 6 seconds.

    This is not the actual time that your statements took to run, but is the time elapsed from when you clicked Start Profiling until profiling completed. If the time reported is much different from what you expected (for example hundreds of seconds for a simple statement), you might have had profiling on longer than you realized.

    Profile time is CPU time. The total time reported by the Profiler is not the same as the time reported using the tic and toc functions or the time you would observe using a stopwatch.

  1. When profiling is complete, the Profile Summary report appears in the Profiler window. For more information about this report, see Profile Summary Report.

Profiling a Graphical User Interface

You can run the Profiler for a graphical user interface, such as the Filter Design and Analysis tool included with the Signal Processing Toolbox. You can also run the Profiler for an interface you created, such as one built using GUIDE.

To profile a graphical user interface, follow these steps:

  1. In the Profiler, click Start Profiling. Make sure that no code appears in the Run this code field.
  2. Start the graphical user interface. (If you do not want to include its startup process in the profile, do not click Start Profiling, step 1, until after you have started the graphical interface.)
  3. Use the graphical interface. When you are finished, click Stop Profiling in the Profiler.
  1. The Profile Summary report appears in the Profiler.

Profiling Statements from the Command Window

To profile more than one statement, follow these steps:

  1. In the Profiler, clear the Run this code field and click the Start Profiling button.
  2. In the Command Window, enter and run the statements you want to profile.
  1. The status bar in the desktop reports Profiler on when MATLAB is not busy and the Profiler is running.

  1. After running all the statements, click Stop Profiling in the Profiler.
  1. The Profile Summary report appears in the Profiler.

Changing Fonts for the Profiler

To change the fonts used in the Profiler, follow these steps:

  1. Select File -> Preferences -> Fonts to open the Font Preferences dialog box.
  2. In the Font Preferences dialog box, select the code or text font that you want to use in the Profiler. The Profiler is an HTML Proportional Text tool. For more information, click the Help button in the dialog box.
  3. Click Apply or OK.
  4. In the Profiler, click the Refresh button to update the display.

Previous page  The Profiler Profile Summary Report Next page

© 1994-2005 The MathWorks, Inc.