Why does instatiating more instances of a MATLAB class take a shorter time in MATLAB 7.9 (R2009b)?
1 次查看(过去 30 天)
显示 更早的评论
I am using a class in MATLAB that I wrote. I find that if I create 10 objects of that class at once, then create 20 objects of that class, the first set of operations actually takes longer. TIC and TOC verify the observed behavior.
采纳的回答
MathWorks Support Team
2010-3-3
The reason for this somewhat odd result can be attributed due to the slow nature of the loading of a MATLAB class the first time. The first time MATLAB loads a new class, it has to do extra processing compared to successive loads. On successive loads, all the class information is already cached, so it is much faster. If you put a "clear classes" statement between the two operations, you will find that the second operation will take longer than the first, due to the fact that the second operation also has to load the class from scratch.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Construct and Work with Object Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!