Is using classes vs. structures more computationally efficient? Especially with parallelization ? What about MATLAB Compiler?
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Michael
am 26 Jun. 2021
Beantwortet: Walter Roberson
am 26 Jun. 2021
There is a discussion about how classes help better structure the code and make more readable, and re-useable, but I haven't seen any comments regarding the efficiency? Both memory and speed?
Woould impemeneting the same simple code as structures + functions be more efficient then defining classes and calling methods?
What about when code is deployed as application using MATLAB compiler, or compiled into MEX?
Thanks,
-MK
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 26 Jun. 2021
Using struct has traditionally been more efficient, as searching for the correct method can be expensive.
The performance of classes was significantly worse before Mathworks implemented the Execution Engine several releases ago.
The performance for anything generated with MATLAB Compiler is the same as interactive, as MATLAB Compiler uses the same execution technology.
The performance for compiled code (C++ generated with MATLAB Coder) is different. A fair bit of research work went into C++ compiler technology to make classes more efficient than they were when C++ started out.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu C Shared Library Integration finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!