c++ function in the mex (S) function is much faster than linux terminal

1 次查看(过去 30 天)
Hi guys. I am testing my c++ code using software in the loop (SIL) test.
When i compare computation time of c++ code execution in the S-function and c++ code execution in the linux terminal,
Former is much faster than latter.
Both used the same compiler (g++) and c++ libraries ( eigen and CLP)
It is hard to figure out how it works and there is no info about this.

采纳的回答

Gaurav Vinay
Gaurav Vinay 2022-11-28
The execution in linux terminal tends to be slower when compared to a S-function since S-functions are already in the binary form of the model, however in SIL the binary gets generated on execution.
Although the SIL simulation happens on the binary generated, the code is generated for the entire model blocks when run on a Linux terminal. This is generally the main cause for the additional execution time.
For a model with S-function, mex files are used, which is already in binary form. Hence there is no generation of blocks into binary again during execution which speeds up the compilation time.
For more information on SIL Simulations, go through the following link:-
Although there is a difference in execution time, the time gap will reduce on subsequent runs of the test in a Linux Terminal as the Binary generated will be cached.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler SDK 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by