A little surprised :) Thought I'd share and ask a NOT rhetorical question. - page 24

 
TheXpert:
It would be perfect to test it on EMA.

Ahem... I don't think that's necessary anymore. The situation has become clearer. As is the custom in this thread - a bit surprised and thought I'd share... :)

Here is an extract from the test, the full test is in the trailer, the library is in there too:

..........
....................
    IntRational ira={2345,3456};
    IntRational irb={67,93};
    IntRational irc={93,67};
    t = GetTickCount();
    for(int i=0;i<Count;i++)
      {
       ira.Div(irb); ira.Div(irc);
       ira.Mul(irb); ira.Mul(irc);
       ira.Add(irb); ira.Add(irc);
       ira.Sub(irb); ira.Sub(irc);
       ira.Norm();
      }
    Print("Common time IntRational test = ", GetTickCount()-t, " ms; // ",Count," calls");
    double da=2345.0/3456.0;
    double db=67.0/93.0;
    double dc=93.0/67.0;
    t = GetTickCount();
     for(int i=0;i<Count;i++)
      {
       da/=db; da/=dc;
       da*=db; da*=dc;
       da+=db; da+=dc;
       da-=db; da-=dc;
      }
    Print("Common time double test = ", GetTickCount()-t, " ms; // ",Count," calls");
..................
......

Results:

2011.04.04 20:29:15 RationalSpeedTest (EURUSD,M20) Common time int test = 62 ms; // 1000000 calls
2011.04.04 20:29:15 RationalSpeedTest (EURUSD,M20) Common time long test = 141 ms; // 1000000 calls
2011.04.04 20:29:15 RationalSpeedTest (EURUSD,M20) Common time double test = 62 ms; // 1000000 calls
2011.04.04 20:29:15 RationalSpeedTest (EURUSD,M20) Common time IntRational test = 1032 ms; // 1000000 calls
2011.04.04 20:29:14 RationalSpeedTest (EURUSD,M20) Common time LongRational test = 921 ms; // 1000000 calls

I was very perplexed: double and int absolutely matched in speed of arithmetic operations and besides, long was the fastest, Rational was completely screwed.

In the light of these experiments I feel a bit reluctant to build an integer tester. :-))

Maybe with other processors the results will be a bit different (I'll be grateful to those who will test and post), but I can't believe in great differences.

Interestingly, once in the unforgotten 90's I tested the difference between integer and floating point operations, the differences were quite noticeable (to put it mildly).

Summary - 90's are over and gone, floating point arithmetic works very fast nowadays.

Even changing it to integer arithmetic is not reasonable (in trading context) - the gain is negligible if not illusory.

Final resume - if Intel doesn't urgently make support of rational arithmetic at iron level, you don't have to worry about it anymore... at least in terms of performance. :)

Amen.

// I'll repeat. The tests were run on a single marmot PC, therefore, in order to avoid falling under any illusions, I'd like to ask everybody to run the test on their computers and post the results with indication of iron parameters.

// My computer: 2 gigs of RAM, Sempron 3100+ 2.2 gigahertz CPU, 32 bit, WinXP operating system

Документация по MQL5: Основы языка / Операции и выражения / Арифметические операции
Документация по MQL5: Основы языка / Операции и выражения / Арифметические операции
  • www.mql5.com
Основы языка / Операции и выражения / Арифметические операции - Документация по MQL5
Files:
 
MetaDriver:

Ahem... I don't think that's necessary anymore. The situation has become clearer. As is the custom in this thread - a bit surprised and thought I'd share... :)



99% of deductions will not require common denominator, so testing is not entirely correct. You have to take the real calculations and do them properly. Inty according to my estimations is 1000000 times faster ( and due to the fact that everything in memory and in cache of the processor) :) The results are simply staggering. Like 2000 runs in 1 second. :)

 
MetaDriver:

Summary - 90's are over and gone, floating-point arithmetic works very fast nowadays.

Even changing it to integer arithmetic is not reasonable (in the context of trading) - the gain is negligible if not illusory at all.

Those who have been programming for the last ...thirty years know it long ago.

Besides, it is not for nothing that we switched to SSE2, for without it there is no general performance improvement.

 
Renat:

Who has been programming for the last ...tundreds of years, has known it for a long time.

It is not for nothing that we switched to SSE2, because without it we won't see any overall performance improvement.

I packed a tick into 32 bits (asc, bid and time). And I got speedup, which is already usable.

:) Plus, I don't run by memory like MT5 - all variants of the search go round the bar, not the other way round. :) Flying !!! :)

**

By the way, if it's not too hard to do it on MT, I wrote there above.

 
Academic:
I put a tick in 32 bits ( asc, bid and time ) . And I got a speed boost, which is already usable.

You can do a lot more than that in a dream... Only practice wakes me up and spoils everything.

But nothing, there will be a new flight of fancy tonight!

 
Renat:

You can do a lot more than that in your sleep... Only practice wakes me up and spoils everything.

But nothing, tonight will be a new flight of fancy!

You're not afraid to be polluted. I'm not lying. :) It's easy to cram. You just have to think about it. Yeah... I'm amazed at the self-confidence in my sleep. :)
 
Academic:
You're not afraid to be polluted. I'm not lying. :) It's easy to cram, you just have to think about it. Yeah... I'm amazed at the self-confidence in my sleep. :)

I don't keep saying "practice" for nothing.

We've been doing extreme bit-by-bit packing of quotes when transmitting over the network for a long time and successfully. The average compression is 1:13, when 10 years of a minute story is compressed into 10-12 mb.

But the practice is that the compression (not to mention mathematical operations on them) of this mess takes so long that speed is out of the question.

 
Renat:

I don't keep saying "practice" for nothing.

We have a long and successful history of extreme bit-by-bit packing of quotes when transmitted over the network. The average compression is 1:13, where 10 years of a minute story is compressed into 10-12 mb.

But the practice is that the compression (not to mention mathematical operations on them) of this mess takes so long that speed is out of the question.

I'm telling you - you need to have experience in programming high-performance applications. You don't have to be a theoretician, it won't take slower to figure out these 32 bits than it takes five machine commands.
 
MetaDriver:
...

Amen.

// I repeat. The tests were run on a separate computer, so, in order not to fall under superfluous illusions, I ask those willing to run the test on their computers and post the results with indication of hardware parameters.

// My computer: 2 Gigs of RAM, Sempron 3100+ 2.2 GHz processor, 32 bit, WinXP operating system

That's what the tough Siberian lumberjacks said too :o)

2011.04.04 20:30:59     RationalSpeedTest (USDCHF,M1)   Common time int test = 78 ms; // 1000000 calls
2011.04.04 20:30:59     RationalSpeedTest (USDCHF,M1)   Common time long test = 125 ms; // 1000000 calls
2011.04.04 20:30:59     RationalSpeedTest (USDCHF,M1)   Common time double test = 94 ms; // 1000000 calls
2011.04.04 20:30:59     RationalSpeedTest (USDCHF,M1)   Common time IntRational test = 1391 ms; // 1000000 calls
2011.04.04 20:30:58     RationalSpeedTest (USDCHF,M1)   Common time LongRational test = 1015 ms; // 1000000 calls
P4 3 Гц [32 бита] 1Гб оперативы, ОС: Windows XP SP 3 версия 5.1 сборка 2600  

Give me another zero in Count for clarity

2011.04.04 20:39:22     RationalSpeedTest (USDCHF,M1)   Common time int test = 718 ms; // 10000000 calls
2011.04.04 20:39:22     RationalSpeedTest (USDCHF,M1)   Common time long test = 1266 ms; // 10000000 calls
2011.04.04 20:39:20     RationalSpeedTest (USDCHF,M1)   Common time double test = 1000 ms; // 10000000 calls
2011.04.04 20:39:19     RationalSpeedTest (USDCHF,M1)   Common time IntRational test = 13156 ms; // 10000000 calls
2011.04.04 20:39:06     RationalSpeedTest (USDCHF,M1)   Common time LongRational test = 9282 ms; // 10000000 calls
 
2011.04.04 22:36:01    RationalSpeedTest (EURUSD,H1)    Common time int test = 63 ms; // 1000000 calls
2011.04.04 22:36:01    RationalSpeedTest (EURUSD,H1)    Common time long test = 94 ms; // 1000000 calls
2011.04.04 22:36:01    RationalSpeedTest (EURUSD,H1)    Common time double test = 47 ms; // 1000000 calls
2011.04.04 22:36:01    RationalSpeedTest (EURUSD,H1)    Common time IntRational test = 734 ms; // 1000000 calls
2011.04.04 22:36:00    RationalSpeedTest (EURUSD,H1)    Common time LongRational test = 594 ms; // 1000000 calls
AMD Phenom 9850 Quad-Core (2.5GHz), 2Gb, WinXP SP3 32