<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Jari,<br>
    <br>
    I noticed that ForEachInteger is extremly slow on loops with high
    ranges.<br>
    And that there is an<b> incredible speed boost</b> on these loops,
    if the script is run a second time.<br>
    <br>
    With the simple print-loop code snippet at very bottom, I get the
    following results for processing time, if I run the loops with these
    values in this order:<br>
    <br>
    endloop=10000   -> 0.214s<br>
    endloop=20000   -> 0.813s<br>
    endloop=60000   -> <b>14.928s</b> <br>
    endloop=160000   -> <b>134.258</b><b>s</b> (!)<br>
    endloop=20000   -> 0.071s (run again with the same 20000   value)<br>
    endloop=60000   -> 0.221s (run again with the same 60000 value)<br>
    endloop=160000   -> 0.566s (run again with the same 160000 value)
    <br>
    endloop=80000 -> 0.282s (although this value was not yet
    calculated it's now done very quickly. Probably because the value
    80000 is below the yet highest value of 160.000) <br>
    <br>
    If you look more deeply into these numbers, it looks like for
    example in the 160.000 loop the 60.000 elements that were calculated
    in the previous run of the script were calculated extremly fast and
    only the remaining new 100.000 elements took very long.<br>
    So if I restart Finale and start with calling the script with
    160.000, it even takes longer than 134 seconds.<br>
    When running the script again with a lower loop end value than
    before, the calculation time is linear and very fast.<br>
    <br>
    Are the Pentium prefetching optimizations really so clever that they
    save 99% of the processing time ?<br>
    I think there must be problem in the implementation as I don't know
    why this simple print loop should take 50s on only 180.000
    iterations on a high speed PC. Maybe it's an iterative memory
    allocation problem: only the first time the memory is allocated and
    then kept free for further loop calls.<br>
    <br>
    Jan<br>
    <br>
    function DoCallback(i)<br>
    print("Callback"..i)<br>
    end<br>
    <br>
    local it=finale.FCLuaIterator()<br>
    it.UseProgressBar=true<br>
    it.AbortableProgressBar=false<br>
    it.ProgressUpdateFrequency=1     <br>
    local endloop=....  --(take value from above)<br>
    it:ForEachInteger(1,endloop,DoCallback)<br>
  </body>
</html>