[Scilab-users] For loop - maximum size
    Tingsten 
    remi.mercier at imelavi.fr
       
    Tue Nov  6 16:48:06 CET 2012
    
    
  
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.
    
    
More information about the users
mailing list