Doug's MATLAB Video Tutorials

Speeding up User Interfaces in MATLAB with profiler 1

Posted by Doug Hull,

Sometimes when you are working on a User Interface you want to use the profiler to speed up the code. However, with a UI so much time can be spent by the user rather than the code of interest that the timing is not as precise as would be preferred.

I like this technique so that I can do ad hock timings as needed in a complicated User Interface in MATLAB.

1 CommentsOldest to Newest

Hi Doug,

In my experience many Matlab programmers are surprisingly unaware that they can turn profiling on and off at will, interactively or programmatically, while a Matlab program is running. Doing so can significantly improve our profiling and performance-tuning effectiveness.

I don’t normally use dedicated GUI controls, since this “soils” my GUI, and I’d need to update the layout. Instead, I typically just run

profile on; ... profile off; profile report"

from the Command Prompt just before starting the workflow-to-be-analyzed. Simpler still, I click the “Start/Stop profiling” button in the Profiler tool. Another simpler alternative is to create two simple shortcuts in the Desktop that start/stop profiling respectively. This obviates the need to update numerous different GUIs separately.

In a related note, I often use the technique of selective workflow profiling to understand how a customer’s GUI behaves and works. I start profiling, interact with a specific GUI part, and then stop profiling and look at the detailed report to see what the code did in this time. It is then easy to step right into the relevant part and start coding/fixing. Customers are often surprised how quickly I can understand and fix their code, when it’s really just the selective use of the Profiler… Let’s keep this trade secret between us, shall we? :-)

Add A Comment

What is 7 + 10?

Preview: hide

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