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
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? :-)