<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Le 03/07/2015 09:42, jaipur a écrit :<br>
    </div>
    <blockquote cite="mid:1435909334253-4032530.post@n3.nabble.com"
      type="cite">
      <pre wrap="">I'm making a big structure (about 110,000 items) by reading data from
Hipparcos star catalog text file.
My procedure is as follows.

MyStruct = struct(); Index = 0;
while ~meof(Fd) do
     ........
     ........
     Index = Index + 1;
     MyStruct(Index).Field1 = ...;
     MyStruct(Index).Field2 = ...;
     MyStruct(Index).Field3 = ...;
end

But this procedure takes huge time!!
The number of items is known. Could you teach me speedy way to make big
structure?
For example, keep memory for structure before starting like 

MyVector = ones(110000,1);</pre>
    </blockquote>
    <br>
    <b>You must use Scilab 6</b>. Handling of structures is much faster
    and optimized with it:<br>
    // at increasing index:<br>
    -->clear s, tic; t=[]; for i=1:1000, s(i).n=%pi; if
    pmodulo(i,10)==0, t(i/10)=toc(); end, end, toc()<br>
     ans  =<br>
        0.7841965<br>
    <br>
    // at decreasing index:<br>
    -->clear s, tic; t=[]; for i=1000:-1:1, s(i).n=%pi; if
    pmodulo(i,10)==0, t(i/10)=toc(); end, end, toc()<br>
     ans  =<br>
        0.391459<br>
    <br>
    // at increasing index after initial sizing:<br>
    -->clear s, tic; t=[]; s(1000).n="abc"; for i=1:1000,
    s(i).n="abc"; if pmodulo(i,10)==0, t(i/10)=toc(); end, end, toc()<br>
     ans  =<br>
        0.413913<br>
    <br>
    <b>Conclusion</b>: for structures arrays,<br>
     - Scilab 6 (aka YaSp) is ~12 times faster than the best of Scilab
    5.5.2<br>
     - initializing the array size still makes things faster. It
    decreases by a factor ~2 the time to fill the array<br>
    <br>
  </body>
</html>