I have created a monster, or at least a lot of MATLAB handle classes that point to each other. For instance, an experiment (handle) is a set of tracks (handles) which contain runs (handle) and reorientations (handle). Then the tracks point pack to the experiment that contains them, the runs and reorientations point back to the track they came from, and they also point ahead and behind to the next run & reorientation.
I have come to realize that all this cross pointing around may confuse MATLAB when it comes time to load or save files, so as much as I can I've defined the handles as Transient and used the set.property methods to define the back pointers. For instance
Track < Handle
properties(Transient = true)
expt;
end
end
Experiment
properties(AbortSet = true)
track;
end
methods
function set.track(obj, value)
if (~isempty(value) && isa(value, 'Track'))
value.expt = obj;
end
obj.track = value;
end
end
This seems to have sped up loading from disk somewhat, but I think I am still missing things.
I can save an experiment to disk, creating a 48 MB file, in about 7 seconds. But it then takes 3 minutes to load the file from disk. I have tried to use the profiler to locate the slow points, but it reports a total time of ~50 milliseconds.
Questions:
Does anyone have experience with saving handle objects to disk and can recommend general practices to speed up loading?
Is there any way to get the profiler to report what matlab is doing with the other 179.95 seconds or a systematic way to determine what is slowing down the loading without using the profiler?