English

## Computing Power Optimization

 2017 gooly 2015.09.09 17:05 #   I would recommend you to do your own tests with a simple script like this (not tested, from scratch):```void OnStart()  {    string strResult;    int  l,loops = 100000;    l=loops;    uint end, beg = GetTickCount();    while( l-->0  && !IsStopped() ){       //do here your first part of measurement    }    end = GetTickCount()-beg;    strResult = "First loop took: "+DoubleToString(0.001*end,3)+" sec\n";    l=loops;    beg = GetTickCount();    while( l-->0  && !IsStopped() ){       //do here your second part of measurement    }    end = GetTickCount()-beg;    strResult = "Second loop took: "+DoubleToString(0.001*end,3)+" sec\n";    Comment( strResult ); }```
 126 Demos 2015.09.25 18:56 #   JCTrading: Thank you all, guys! I was able to perform speed tests on my codes diveded by sections; sometimes I had 78hs remaining in the backtester without heavy or large parameters to check.Problem was in some nested loops. Kept the logic with a different approach and everything went ok.hello again,I see you were having some problems with loops. Well, regarding that aspect I have some remarks to do, which may be usefull , even though you have resolved your issues, as you are saying. So, while "experimenting" with some C code, I came accross the following bottle-neck situation, regarding the following nested loops (here, all the code is for MQL, but it is the same, nevertheless)```    uint begin, end;          int a, b;     static int table[16384][16384]; /* static, because table is a local array, that goes into stack. As such, it is too large for that; static                                        will get it to the heap - or else it could be defined as a global variable, in which case, it should be                                        brought to the heap as well */     begin=GetTickCount();     for (a=0; a<16384; a++)     {         for (b=0; b<16384; b++)         {             table[b][a]=b;          /* next time, swap the order, so it should be table[a][b]=b; */         }     }                end=GetTickCount();          Alert("Time passed is ",( (float)end-begin)/1000,"s");```(Normally, the above goes into OnInit()) The bottle-neck happens in the line "table[b][a]=b;". Of course, normally, since the first for is about a, and the second about b, you would, most likely, write the loop as "table[a][b]". But, if for some reason you put b before a, the compute time goes 2 and 1/2 (not the TV series) times up (from 4 to 10 secs). What's more, while in C, it goes from about 1.5 seconds in my PC, to about 8 secs, which is 5 to 6 times more.best regards