Handles array access speed

3 ビュー (過去 30 日間)
Franck AUBINEAU
Franck AUBINEAU 2020 年 2 月 19 日
Here is my class :
classdef MyClass < handle
properties (Access = protected)
indice;
end
methods
function this = MyClass()
end
end
end
And here is my fisrt code :
numLoop = 200000;
numTab = 100;
pClassRef = MyClass();
for i=1:numLoop
for j=1:numTab
pClass = pClassRef;
end
end
And here is my second code :
numLoop = 200000;
numTab = 100;
tabClassRef(numTab) = MyClass();
for i=1:numLoop
for j=1:numTab
pClass = tabClassRef(j);
end
end
The first code takes 0.5 s
The second code takes 18 s
Why access to an element of my handles array is so long ?

回答 (0 件)

カテゴリ

Help Center および File ExchangeConstruct and Work with Object Arrays についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by