Red Cloud with MATLAB/Profiling

From CAC Documentation wiki
Jump to navigation Jump to search

Profiling MATLAB code

MATLAB provides the profile command that can be used for debugging and optimizing MATLAB code by tracking execution time. The following describes how to create a profile of your code and create a zip file of the results.


To interactively inspect your code you can run the following then browse the results.

>> profile on
>> [Execute your code]
>> profile off
>> profile viewer

For example, if you were to profile MATLAB’s pctdemo_task_bench function you would get an output that looks like the following: Prof1.gif

Clicking on the function name lets you view more detail: Prof2.gif

Saving Results

To save the results for later review you can use the profsave function to store the results as HTML files

>> profsave(profile(‘info’),’profile_demo’);

This creates output that looks similar to the interactive profile: Prof3.gif

To save these results to a zip file you can use the zip function:

>> zip('profile_demo','profile_demo/*');

This creates a zip file “” that contains the contents of the folder “profile_demo”.

Additional information is available from MathWorks