For everyone to know which MATLAB verison I am running , this is it: MATLAB Version: 126.96.36.1994444 (R2018b).
My question is simple, Should i or should i not use enumerations in MATLAB if performance is important?
Im my code, i have the following object and enumeration defined
classdef Object < handel
Dependency (1,1) DependencyType
classdef DependencyType < uint8
The class have a property called Dependency whouch should be of type DependencyType and DependencyType is an enumeration and a subclass of uint8.
In another function, not a member of the class, i have an if-statement that looks like follows
if obj.Dependency == DependencyType.NONE
When I am running the profiler, the if-statement line takes up 35% of the execution time of the function, the function is called 100000 ish times. I wonder if using enumerations in MATLAB is slow or if this is just an overhead of the profiler? I have not found any information regarding this while looking on the internet! I cant understand why it would be slow since there should not be any type conversions. So it must be due to profiling being turned on, but I cant be sure!
If this is not just some overhead from the profiler, then whats wrong. Is it constantly createing new DependencyType objects in the if-statement? Am I doing the comparison wrongly? Why does the comparison take so long time compared to the rest of the code that is way more computationaly demanding in the function.