Why does my GUI execute an order of magnitude faster when I turn on the profiler?

1 view (last 30 days)
I have created a GUI which when run, executes in 9 seconds consistently. When the profiler is turned on, the GUI executes in 1.2 seconds consistently. When the profiler window is opened, the GUI executes in 0.7 seconds consistently.
% Run your GUI
% Execute the callback in your GUI (may be by selecting/clicking a UICONTROL)
profile on % Code executes faster
profile viewer % Code execution speed improves further

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The behavior observed is not a bug in MATLAB.
It occurs because the JIT is unable to completely compile the code the first time the callback is executed. This happens when a variable in the handles structure is not set before it is used in a callback function. For this reason, the JIT accelerator is unable to completely compile this code and hence the slower execution. Doing a JIT on/off, clear all, or profiler on/off after running the code once forces the JIT to recompile the callback function when the variable has already been set and becomes visible to the JIT.
To resolve the issue, set the variable in the handles structure before using it in the callback function.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2007b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!