Speed comparison. How fast is AFL?

I have performed another simple benchmark how fast the AFL array processing is compared to standard loop based programming in another language, in my case vbNet.

AFL for single ticker, using explore function:

GetPerformanceCounter(True);
myArray = O + H + L + C;
elapsed = GetPerformanceCounter();
_TRACE(elapsed);

AFL for multiple tickers, using backtest function:

myArray = O + H + L + C;
Buy = 0;
Sell = 0;

vbNet:

Dim myList As New List(Of Double)
Dim myWatch As New Stopwatch
myWatch.Restart()

For Each Ticker In OHLCdict  'All tickers are stored in RAM in a dictionary of lists.

For Each Bar In Ticker.Value
myList.Add(Bar.O + Bar.H + Bar.L + Bar.C)
Next

Next

Debug.Print(myWatch.ElapsedMilliseconds)

AFL ran on 2 cores (AmiBroker 6.0 64 bit) and vbNet on 1 core.

AFL:
1 ticker (26000 hourly bars) = 100-120 ms
2200 tickers = 5 s

vbNet:
1 ticker (26000 hourly bars) = 0-1 ms
2200 tickers = 1.4 s

Everyone says that array based processing of AFL is way faster than traditional programming.
Why is this not the case in my test?
Do I have misconfigured something?

1 Like

Your test is incorrectly executed, misleading and simply false.

  1. Your AFL results for single symbol are plain and simply FALSE

    The AFL execution of the code for 26000 bars is well below 1ms. (actually average time is 0.1ms). That is 1000x times FASTER than your claim.
    (see video below)

  2. Data access for multiple symbol
    In AFL you are reading data from DISK.
    DISK access is 1000x slower than RAM.
    In your vbNet you have everything already in RAM.
    You also don't even say if you were using compressed data (I guess so, that you were 1-minute data and compressed to one hour and the on-the-fly DATA COMPRESSION you neglected gives you wrong results)

  3. In multiple symbol case you are executing AFL program N-th times and comparing to just ONE execution of vbNet
    N-times program invocation (AFL) vs double nested loop (vbNet)

  4. Your vbNet timing is wrong because Stopwatch resolution is very poor (that explains why once you get result of zero (it is rounded down) and once you get 1.

  5. The AFL formula you given here contains SYNTAX ERROR and it won't even run without changes.

I fixed your formula and applied it on 26000 bars:

GetPerformanceCounter(True);
myArray = O + H + L + C;
elapsed = GetPerformanceCounter();
Title = StrFormat("Number of bars %g, Time elapsed %g [ms] ", BarCount, elapsed );
_TRACE( Title );
Plot( myArray, "myArray", colorRed );

Timings are now displayed in title and in log window:

video

As can be seen, average execution time for your AFL and 26000 bars is 0.1 ms.

The conclusion is that

AFL is 10 times FASTER than your vbNet. (That assumes that your vbNet results are correct, but given "quality" of your other findings...).

To get proper knowledge, read this:
http://www.amibroker.com/kb/2008/08/12/afl-execution-speed/

BTW: I really hate the fact that instead of doing productive work I have to waste my time on debunking nonsense. It really takes an hour that I could use to write a NEW functionality in AmiBroker. But no, I have to sit and do the test for some random unregistered guy proving him wrong, which is total waste of time that could be spent much much better. Next time triple check your "findings" before wasting other people time.

13 Likes