Ken & Mike on the MATLAB Desktop

June 23rd, 2008

Profiling using run configurations

We talk a lot about work flows here on the Inside the MATLAB Desktop blog, as well as ways you can streamline your interactions with MATLAB. For the Editor-centric folks in the audience, here’s a great way to integrate Profiling into your workflow using run configurations.

Profiling run configurations will let you tweak the performance of your code more iteratively. You’ll be able to work from the Editor, press the run button, inspect the performance, and then go right back to your code to tweak it.

To setup a profiling run configuration, start by opening the file you’d like to improve the performance of in the MATLAB Editor. Then, open the Configuration Editor by pressing the drop-down arrow on the run button , and select Edit Run Configurations for [your file]. In the MATLAB Expression area, put the following commands, where your_function is the function to profile:

% start profiling.
profile on;
% call your function here.
your_function
% stop profiling.
profile off;
% show the profile viewer.
profile viewer;

Which should look something like this:

Close the Configuration Editor when your done.

Back in the Editor, you can click the run button (or press F5) and your code will be profiled. The Profiler will popup after running your function, so you’ll be able to immediately inspect the results, teak your code and re-run your function. To prevent the Profiler from obscuring the Editor, try docking it in the Desktop. This is a great technique for iterativley improving your code’s performance.

Check out the MATLAB documentation for more information on the profile function.

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Ken & Mike work on the MATLAB Desktop team.
  • DP: Hi i have a problem with ezplot3, i want to plot more than i curve in the same graph but hold on command...
  • Ken: Hi Arsalan, Unfortunately there is no way to get the new Editor API in older versions of MATLAB. -Ken
  • Arsalan: Hi, I am very excited about the MATLAB API for editor because right now i am working on a project and i need...
  • Johannes: Since I started using matlab-emacs some days ago I never experienced Emacslink. But I experienced some...
  • Francisco J. Beron-Vera: Hi all, I have recently learned about ViEmu (http://www.vimemu.c om) which, for Vi/Vim...
  • OysterEngineer: When I first learned of the Publish feature in MatLab, I thought it might be useful to help to...
  • Ken: Hi Herve, I’m not quite sure what you mean by “stand-alone&# 8221; mode? -Ken
  • Herve: I wonder when the publish fonction will be supported in standalone mode.
  • Mike: Ravi, What you described should work as far I understand it. Please follow up with technical support. With a...
  • Mike: @Daniel, Thanks for that note.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.