How do I profile block or mask initialization times in Simulink 6.4.1 (R2006a+)?

1 view (last 30 days)
I had a Simulink model that took a long time to update. After spending some time going through the model, the issue turned out to be a very expensive mask initialization routine.
Is there a way to see this initialization cost in the Simulink Profiler to more quickly identify these issues in the future?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
Currently there is no direct way to view initialization time costs in Simulink.
As a workaround, you can utilize the MATLAB Profiler along with the Simulink update diagram to obtain this information. An example is attached.
The attached profile_model.mdl has two masked subsystems. The first one, profile_model/Subsystem, has a mask initialization command that calls the mywrapperfunction.m:
mywrapperfunction(1)
This MATLAB file executes a simple PAUSE command. This command is one second long, so it will stand out from the rest of the update calculations. profile_script.m contains:
clear all
open_system('profile_model')
profile on
set_param('profile_model','SimulationCommand','update')
profile off
profile viewer
These are the steps to update the model and profile via the command line. This utilizes MATLAB to open the model, update the model, and profile the update action. The results will show mywrapperfunction as the most expensive calculation in the update diagram call (see attached profile_screenshot.jpg).
Note the first run of profile_script.m may produce a slightly different run than the screen shot. In any case, mywrapperfunction should be the most expensive calculation.
Also note that currently there is no way to map the MATLAB functions back to a particular block mask initialization.

More Answers (0)

Categories

Find more on Multicore Processor Targets in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!