Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Gaurav Vinay
Gaurav Vinay il 28 Nov 2022
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.

Più risposte (0)

Categorie

Scopri di più su MATLAB Compiler SDK in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by