Why does the Profiler show substantially different results for the same code?

I want to use the profiler "bar map" at the top to show students how to use and analyze code using the profiler in MATLAB R2020a
-A single click only shows non-built in function in the bar map.
-A double click shows built in and non-built in functions sometimes, and sometimes only non-built in functions.
Why do I see this behavior, and how can I make it more consistent?

 Accepted Answer

When you profile the code from the profiler window, it captures all the code that runs there. This can be different code from what is running when using the MATLAB Command Window.
If you click too quickly, you could restart profiling while MATLAB was still working on cleaning up the workspace. I was able to reproduce this behavior - showing extra information - when rapidly clicking the 'Run and Time' profiling button.
As a workaround, single clicking should show consistent profiling results. Alternatively, hitting "Enter" from the text input where the script name is should also avoid double execution.

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Release

R2019b

Community Treasure Hunt

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

Start Hunting!