[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: NOT REALLY A BUG



PureBytes Links

Trading Reference Links

Tomasz,
Thank you for your reply.
Here is an example:
The 
//Code1
for(I=1;I<10^5;I++)
{
X=MA(C,0.001*I);
}
Plot(X,"["+I+"]",colorBlack,1);

needs ~25sec.
The

//Code2
function SMA(PER)
{
return MA(C,0.001*PER);
} 
for(I=1;I<10^5;I++)
{
X=SMA(I);
}
Plot(X,"["+I+"]",colorBlack,1);

did not improve the speed.
I do not know *how* could I come to the final result in 5sec, I do 
not know how to remove the moving parts from the body of the loop, I 
do not know the cost of an if/else statement inside the loop.
So, when I begin thinking of "the closest MA" [a quite interesting 
issue...] I need an iteration with MAs and an if statement to apply 
the proximity criterion [or a while statement to stop the execution 
when the C-SMA is minimum.]
If I come to some 10-15 sec code, it is OK, I can keep on the initial 
thought and, probably, come to an interesting result.
If my code needs 2min, I will simply forget all about it and move to 
another issue.
Life is short, on the other side, there is no time to study 
programming books.
The *only* use, for me, would be the flexibility of my AFL loops, I 
do not need programming for other applications.
[Even my weather forecasting formulas are written in AFL !!]
This is why I thought you could write an "AFL looping guide", 
whenever of course you decide to use 0.5h from the precious time 
devoted to Julia and Jacob !!!
Have a great day !!
Dimitris 
--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
wrote:
> Dimitris,
> 
> The example was intented to show that implementation of AFL 
language contructs
> (like loops) is very, very fast.
> So using loops is not a problem at all.
> 
> Problems may start when _the_ _formula_ _you_ _put_ _inside_ the 
loop
> is written in inefficient manner.
> I already wrote about some basic techniques like moving invariants
> out of loop plus using variables and calling functions once instead
> of repetitive calling the same functions with same params over and 
over again. 
> If such inefficient code is wrapped inside several nested loops it 
will
> execute slowly no matter in what language is written. Even if you 
wrote it
> in assembler (straight machine CPU code)
> 
> These are basic things covered in each and every
> book on programming (i.e. they are language-independent, because
> these are 'universal' programing rules not depending on particular 
language).
> 
> But thank you for your suggestion - I will think about writing some 
article
> about good programming practices in next newsletter.
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Friday, October 01, 2004 8:01 AM
> Subject: [amibroker] Re: NOT REALLY A BUG
> 
> 
> > Tomasz,
> > Your example is a bit strange. AFL does not need 5sec for 10 
million 
> > iterations, it is not a global measure, the total time depends 
> > strongly on the code. It will not be 5 sec if we use an MA 
instead of 
> > the sin function, it will be 5min and the total time will be much 
> > longer if a Plot statement is added inside the loop.
> > It would help to write some basic "rules" for the execution time 
of 
> > AFL loops [perhaps in some next newsletter] and some instructions 
how 
> > to "optimize" AFL loops.
> > Dimitris
> > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
<amibroker@xxxx> 
> > wrote:
> >> Hello,
> >> 
> >> You should optimize your formula first so it does not ages to 
> > execute.
> >> 
> >> If your formula takes more than 1 second to execute you probably
> >> did something very weird or wrong because AFL itself including 
> > loops are hyper fast.
> >> 
> >> For example TEN million iteration of sine function like this:
> >> for(i=0;i<10000000;i++)
> >> {
> >>  x = sin(i);
> >> }
> >> 
> >> Takes only five seconds, so it takes 0.5 microsecond per 
iteration 
> > (including calculation
> >> of trigonometric function).
> >> 
> >> (Note that if you want to try this code you would need to adjust 
> > the endless loop detection
> >> threshold level in Tools->Preferences->AFL to more than 10 
million 
> > loops, otherwise you will
> >> get endless loop warning).
> >> 
> >> Best regards,
> >> Tomasz Janeczko
> >> amibroker.com
> >> 
> >> ----- Original Message ----- 
> >> From: "s.carrasset" <s.carrasset@xxxx>
> >> To: <amibroker@xxxxxxxxxxxxxxx>
> >> Sent: Thursday, September 30, 2004 3:55 PM
> >> Subject: [amibroker] NOT REALLY A BUG
> >> 
> >> 
> >> > hello, Tomasz.
> >> > 
> >> > it can happens ( rarely ^_^) that I get a "displeasure" with 
> > amibroker.
> >> > where can I send it , here or support?
> >> > for ex the last one:
> >> > 
> >> > if I write or paste a code with many loops  (with no error 
> > inside)  like 
> >> > the last one parabolic code of  Dimitri in message 71077.
> >> > 
> >> > Amibroker becomes very slow to open the symbol workspace even 
if 
> > i close 
> >> > the code's window on the  displayed  chart pane.
> >> > 
> >> > stephane
> >> > 
> >> > 
> >> > 
> >> > Check AmiBroker web page at:
> >> > http://www.amibroker.com/
> >> > 
> >> > Check group FAQ at: 
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> >> > Yahoo! Groups Links
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> >
> >> 
> >> [Non-text portions of this message have been removed]
> > 
> > 
> > 
> > 
> > Check AmiBroker web page at:
> > http://www.amibroker.com/
> > 
> > Check group FAQ at: 
http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > Yahoo! Groups Links
> > 
> > 
> > 
> > 
> > 
> >



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/