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
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 个)

类别

Help CenterFile Exchange 中查找有关 Construct and Work with Object Arrays 的更多信息

标签

尚未输入任何标签。

产品


版本

R2009b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by