About‎ > ‎

Performance tests


To be finished...
Three AFL scripts that employ loops were picked from the AFL Library. The full code and the loop code of these AFL scripts were converted into .NET plugins. So the very same "trading logic" was implemented in three forms for the comparision tests:
1. As they were downloaded from the AFL library.
2. They got converted to a fully .NET AFL plugin (all code got converted).
3. They got converted to an AFL + .NET plugin solution where only the code that employ the loop were converted to compiled .NET plugin.


To be finished...
1. Compiled .NET loops have significant (>10x) performance advantage over AFL script loops (see Test case 1).
2. In real life trading systems the code logic consists of loops and other array operations that are handled by built-in AmiBroker functions or by .NET for AmiBroker array operators (see Test case 2 and Test case 3). Converting the loops alone can give a 20-50% time saving in total backtesting time. Converting whole AFL scripts may (Test case 2, ~1.5x vs. ~2x performance) or may not (Test case 3, ~1.4 vs. 1.5x performance) justify the investment of conversion. If the script consists of a lot of array operations (addition, multiplication, comparision, etc), its performance can be greatly improved by conversion.

Test method

To be finished...

Test Results

The below tables and screen shots show the results of perfromance tests at different number of used bars while using the original and the converted solutions.

Test case 1 : Signal to Noise

This AFL's logic consists of a single loop of all bars. The loop's body has complex calculations that use many arrays. Almost no other code can be found in the AFL file so it is a good candidate to show how AFL and .NET loops' performance compare.
No. of used bars Test case 1: Signal to Noise x86 x64
Speed (bar/ms) Speed up Speed (bar/ms) Speed up
1 000 bars AFL 80.6   72.0  
.NET 1295.5 16.1 X 1517.0 21.1 X
10 000 bars AFL 85.0   78.8  
.NET 1379.7 16.2 X 1574.7 20.0 X
100 000 bars AFL 87.2   79.7  
.NET 1418.0 16.3 X 1609.4 20.2 X

Test case 2 : Automatic Trendlines using Multiple Timeframes

No. of used bars Test Case 2 : Automatic Trendlines using Multiple Timeframes x86 x64
Speed (bar/ms) Speed up Speed (bar/ms) Speed up
10 000 bars AFL 686.1   682.4  
Mixed (AFL and .NET) 945.3 1.4 X 1038.6 1.5 X
.NET 1214.5 1.8 X 1429.3 2.1 X
100 000 bars AFL 523.1   492.2  
Mixed (AFL and .NET) 893.7 1.7 X 1034.3 2.1 X
.NET 1113.8 2.1 X 1196.4 2.4 X

Test case 3 : Automatic Linear Trend Channel 2

This AFL script is rewritten to a mixed version (only the loop is converted to .NET) and to a .NET version (all code, including all calculations and plots are done in .NET)
The loop of bars is not too complex. Converting the loop gives the base of the performance advantage (~2X speed up). Converting the rest of the code does not improve performance significantly.
No. of used bars Automatic Linear Trend Channel 2 x86 x64
Speed (bar/ms) Speed up Speed (bar/ms) Speed up
1 000 bars AFL 211.9   210.5  
Mixed (AFL and .NET) 252.0 1.2 X 267.5 1.3 X
.NET 388.7 1.8 X 447.4 2.1 X
10 000 bars AFL 301.8   306.7  
Mixed (AFL and .NET) 374.3 1.2 X 411.9 1.3 X
.NET 410.7 1.4 X 441.1 1.4 X
100 000 bars AFL 308.0   328.9  
Mixed (AFL and .NET) 401.4 1.3 X 488.9 1.5 X
.NET 419.7 1.4 X 491.3 1.5 X