Programming and Data Types    

Using Information in the Profiler Reports

These are some guidelines for using the information provided by the Profiler reports.

Process for Improving Performance.   Here is a general process you can follow to use the Profiler to improve performance in your M-files.

  1. In the Profile Summary report, look for functions that used a significant amount of time or were called most frequently.
  2. View the detail report for those functions and look for the lines that use the most time or are called most often.
  1. You might want to copy the detail report to its own window using the Copy to new window link near the top of the detail report. The copy will be a reference to compare with after you make changes and profile again. You can also print a report by clicking the print button .

  1. Determine whether there are changes you can make to the lines most called or the most time-consuming lines to improve performance.
  1. For example, if you have a load statement within a loop, load is called every time the loop is called. You might be able to save time by moving the load statement so it is before the loop and therefore is only called once.

  1. If lines are not accelerated (there is an x in the Acc column of the detail report), particularly those that are called frequently or use significant time, click the x for information about why they were not accelerated. This is an example.

  1. Determine whether there are changes you can make to the lines so they can be accelerated. For details, see Performance Acceleration. Most code includes lines that are not accelerated. As long as your code runs acceptably fast, you do not need to have every statement accelerate.

  1. Click the links to the files and make the changes you identified for potential performance improvement. Save the files and run clear all. Run the Profiler again and compare the results to the original report. Note that there are inherent time fluctuations that are not dependent on your code. If you profile the exact same code twice, you can get slightly different results each time.
  2. Repeat this process to continue improving the performance.

Using the Profiler for Debugging.   The Profiler is a useful tool for isolating problems in your M-files.

For example, if a particular part of the file did not run, you can look at the detail reports to see what lines did run, which might point you to the problem.

You can also view the lines that did not run to help you develop test cases that exercise that code.

If you get an error in the M-file when profiling, the Profiler provides partial results in the reports. You can see what ran and what did not to help you isolate the problem. Similarly, you can do this if you stop the execution using Ctrl+C, which might be useful when a file is taking much more time to run than expected.

Using the Profiler for Understanding an M-File.   For lengthy M-files that you did not create or that you have not used for awhile and are unfamiliar with, you can use the Profiler to see how the M-file actually worked. Use the Profiler detail reports to see the lines actually called.

If there is an existing GUI tool (or M-file) similar to one that you want to create, start profiling, use the tool, then stop profiling. Look through the Profiler detail reports to see what functions and lines ran. This helps you determine the lines of code in the file that are most like the code you want to create.


  File Listing Changing Fonts for the Profiler