%% Introduction to Profiling Models
% This example shows how to use the *Simulink Profiler* to examine the
% slAccelDemoF14 model and identify issues that can contribute to poor
% simulation performance. Consider using the *Simulink Profiler* to
% manually optimize model settings, identify simulation slowdowns, and
% resolve performance bottlenecks.
%
% To automatically optimize your model and achieve faster simulation, see
% <docid:simulink_ug#btht9fu-2 Improve Simulation Performance Using
% Performance Advisor>.
%
% To learn more about accelerator modes for faster simulation, see
% <docid:simulink_ug#brc689t What Is Acceleration?>.
%
% Copyright 1990-2021 The MathWorks, Inc.
%% Activate the Profiler
% To activate the Simulink(R) Profiler, in the Simulink Editor, on the
% *Debug* tab, under *Performance Advisor*, click *Simulink Profiler*. You
% can also issue a |set_param| command at the command prompt.

modelName = 'slAccelDemoF14';
load_system(modelName)
set_param(modelName,'Profile','on');

%% Run Simulation
% While the simulation runs, the profiler is collecting data for the report.
% Once the simulation is complete it creates an HTML report.

open_system(modelName)
sim(modelName);

%% View Report
% A detailed profiling report is shown in a docked panel on the Simulink
% Editor. Select a row to see the breakdown of the self-time of
% the specific model element in the Property Inspector. 
% 
% <<../report.png>>
% 

%% Share Report 
% You can share the profiling report with others as an HTML report or as a
% MAT file. To share your profiling run, select the desired run from
% the *Run* menu of the Profiling Report. Then select your desired export
% format from the *Share* menu on the Toolstrip.