Exponentially slow save rate with -v6
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nicholas Vitale
le 25 Juil 2014
Commenté : Nicholas Vitale
le 28 Juil 2014
Hi, I am trying to save a hours worth of recording that has been split up into sections of 5,500 frames (uint8) which is under the 2GB cap that the -v6 is limited too. Saving these groups of 5,500 as their own .mat file (yes I know not the best way to do this), is pretty fast in the command window. Ran 20 times in a for loop avg. time was around 18 seconds per group. However, the script I wrote, using the same exact commands to save 20 groups it takes anywhere from 25 - 66 minutes which is not optimal or my research. Any reasons why the save gums up?
3 commentaires
Geoff Hayes
le 26 Juil 2014
Nicholas - perhaps attach some (or all) of the code that is in your script so we can see what it is doing.
Réponse acceptée
Geoff Hayes
le 28 Juil 2014
To be clear - savedFrames is a cell array of 5500 frames, and is one of 30 slots within a greater cell array. Does this mean that maxCycle is 30?
On each iteration of the for loop, the code copies the 5500 frames from the ith slot of savedFrames into the placeholder dummyCel
dummyCel{i} = savedFrames{i};
Note that dummyCel is being treated as a cell array and that its ith slot is being updated at each iteration - so it is growing at each iteration of the loop! So not only is the code writing out the 5500 frames (to the mat file) from the current iteration, but it is including the 5500 frames from each of the previous iterations as well. So each mat file is getting larger and larger, and the time to write out each is taking longer and longer.
I think that you want to replace your above code with just the following (or something like this, I truncated the name to work on my computer)
for k = 1:maxCycle
dummyCel = savedFrames{k};
save(sprintf('FramePackage%d.mat',k),'dummyCel','-v6');
end
There is no need to clear the ith slot of savedFrames. Note that all files will have the same named variable in each, dummyCel. Unless, by using dummyCel{i}, were you trying to give each a distinct name?
NOTE that in the above code, I replaced i with k since i and j are used by MATLAB as representations for the imaginary number.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!