BusSelector InputSignals computation time exploses (M2016b->M2022b)
2 views (last 30 days)
Show older comments
Hello,
I'm testing a MATLAB script on a SIMULMINK model made of 1727 models, migrated from M2016b environment to M2022b environment.
The purpose of the script is to build a predecessor list for each model while analyzing the connections of the signals.
I've noticed the computation time to retrieve the list of input signals from BusSelector blocks has highly increased from M20163b to M2022b
With profiler, the following function
bus = get_param(handle, 'InputSignals');
can take 70-90 sec sometimes whereas it was never exceeding 1s before (M2016b).
Please see the screenshots from profiler
Is there any reason why this computation time can increase so much, and what king of workaround can I test.
As I'm analyzing the list of predecessors from each model inports, if I find a busSelector, I'm analyzing the signal names to compute the indexes within the bus structure where my signal is located in order to apply the same indexes when I meet the corresponding BusCreator blocks to continue the ascending propagation analysis.
0 Comments
Answers (1)
Ayush
on 5 Aug 2024
Edited: Ayush
on 5 Aug 2024
Hello Michael,
It seems like you are experiencing some performance problems in your script while transitioning from MATLAB R2016b to MATLAB R2022b. Such an instance can occur due to several changes in the internal infrastructure as well as how large models are handled across releases. I would suggest you to try the following workarounds to overcome the performance bottleneck:
1. Use a caching mechanism to store the retrieved input signals and thus optimize performance. You can refer to the below documentation page to understand how to leverage "Simulink Cache" for the same:
2. If possible, you can also try to batch process retrieval of input signals using the "get_param" function by iterating it over a loop ,storing the values in an array and parallelizing this whole process using the Parallel Computing Toolbox. This would in turn reduce the time overhead and lead to an optimized performance. Here is an example code snippet for your reference:
function inputSignalsMap = getParallelInputSignals(handles)
inputSignalsMap = containers.Map('KeyType', 'char', 'ValueType', 'any');
parfor i = 1:length(handles)
handleStr = num2str(handles(i));
inputSignalsMap(handleStr) = get_param(handles(i), 'InputSignals');
end
end
You can also refer to the below documentation to know more about the "parfor" function to perform parallel computing:
Hope this helps!
0 Comments
See Also
Categories
Find more on Configure and View Diagnostics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!