Hi Remi,
but the better way to do this is
timer();A=zeros(1,100000);for i=1:100000,A(i)=i;end;timer()
it is probably linked with how Scilab handles its memory
Calixte
On 06/11/2012 16:48, Tingsten wrote:
Hello everybody,
I assume this kind of talk about the effectiveness of the For loop in Scilab
has been discussed many times but I was not able to find a recent topic
about it....
I am usually post-processing big csv files and by reading them I noticed
some important time change depending of the architecture of the loop.
So i did some very quick and simple tests with the following results :
1)timer();A=[];for i=1:100000,A=[A;i];,end;timer()
ans =
16.598506
2)timer();B=[];for j=1:10,A=[];for
i=1:10000,A=[A;i];,end;B=[B;A];,end;timer()
ans =
1.0452067
3)timer();B=[];for j=1:100,A=[];for
i=1:1000,A=[A;i];,end;B=[B;A];,end;timer()
ans =
0.4992032
4)timer();B=[];for j=1:1000,A=[];for
i=1:100,A=[A;i];,end;B=[B;A];,end;timer()
ans =
0.9204059
5)timer();C=[];for h=1:10,B=[];for j=1:100,A=[];for
i=1:100,A=[A;i];,end;B=[B;A];,end,C=[C;B];,end;timer()
ans =
0.4524029
It is probably explainable but interesting to know that 3) is 30 time better
than 1).
So I would think that it is totally forbidden to be efficient to do loop
10000.
Any comment or advice about that?
Thx you a lot,
RĂ©mi Mercier
--
View this message in context:
http://mailinglists.scilab.org/For-loop-maximum-size-tp4025172.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at
Nabble.com.
_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
--
Calixte Denizet
Software Development Engineer
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
http://www.scilab-enterprises.com
_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users