-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Description
Summary
It seems that the BlockInitialization MATLAB function takes a lot of time to execute in some models, impacting a lot the time necessary to start a simulation.
Motivation
Profiling in some Simulink models that use WB-Toolbox revealed that during Simulink model compilation ( https://de.mathworks.com/help/simulink/ug/simulating-dynamic-systems.html#f7-8245 ) . In particular, it seems that the part that costs more in term of time is the following loop:
wb-toolbox/matlab/+WBToolbox/BlockInitialization.m
Lines 30 to 44 in 114ac0e
% Look a config block from the block's scope going up in the tree | |
analyzedScope = blockScopeName; | |
configBlock = char; | |
while ~isempty(analyzedScope) | |
rule = strcat(strrep(analyzedScope,'/','\/'),'\/\w+\/ImConfig'); | |
idx = cellfun(@(x) ~isequal(regexp(x,rule),[]), blocks_system); | |
if (sum(idx) > 1) | |
error('[%s::Initialization] Found more than one configuration', char(currentBlock)); | |
elseif (sum(idx) == 1) | |
configBlock = blocks_system{idx}; | |
configBlock = fileparts(configBlock); | |
break; | |
end | |
analyzedScope = fileparts(analyzedScope); | |
end |
Additional context
Further profiling to understand which line of
wb-toolbox/matlab/+WBToolbox/BlockInitialization.m
Lines 30 to 44 in 114ac0e
% Look a config block from the block's scope going up in the tree | |
analyzedScope = blockScopeName; | |
configBlock = char; | |
while ~isempty(analyzedScope) | |
rule = strcat(strrep(analyzedScope,'/','\/'),'\/\w+\/ImConfig'); | |
idx = cellfun(@(x) ~isequal(regexp(x,rule),[]), blocks_system); | |
if (sum(idx) > 1) | |
error('[%s::Initialization] Found more than one configuration', char(currentBlock)); | |
elseif (sum(idx) == 1) | |
configBlock = blocks_system{idx}; | |
configBlock = fileparts(configBlock); | |
break; | |
end | |
analyzedScope = fileparts(analyzedScope); | |
end |
Giulero and nunoguedelha