Which is faster - Floating-Point or Integer arithmetic? - page 5

 

Hmmm.... Perhaps the definition of the word "evidence" is being lost in translation....

We were testing the theory that converting a double to an int and performing comparisons furthermore as int was "more efficient". I posted evidence that you needed 2500 (two-thousand five-hundred) comparisons in MT5 as int in order to break-even.

You don't want to accept the new evidence, but instead want to resort to ad-hominems and straw-men.  Real mature fellas.

 
nicholishen:

Hmmm.... Perhaps the definition of the word "evidence" is being lost in translation....

We were testing the theory that converting a double to an int and performing comparisons furthermore as int was "more efficient". I posted evidence that you needed 2500 (two-thousand five-hundred) comparisons in MT5 as int in order to break-even.

You don't want to accept the new evidence, but instead want to resort to ad-hominems and straw-men.  Real mature fellas.

You are the only one who used ad-hominen, straw-men, ad-personam and more... Now that's enough.

Read the topic again, until you understood you are wrong and admit it. If you can't, that's ok, but we are not responsible for that. Grow up.

The topic is closed.

 
Alain Verleyen:

You are the only one who used ad-hominen, straw-men, ad-personam and more... Now that's enough.

Read the topic again, until you understood you are wrong and admit it. If you can't, that's ok, but we are not responsible for that. Grow up.

The topic is closed.

I read the topic again. I see that I tested the theory of int conversion and proved that it takes 2500 comparison operations to offset the latency load of a single double to int conversion on an Intel i5 processor. 
 
nicholishen:
I read the topic again. I see that I tested the theory of int conversion and proved that it takes 2500 comparison operations to offset the latency load of a single double to int conversion on an Intel i5 processor. 

The problem is nobody talked about comparison operations, but about arithmetic operations. Feel the difference.

 
Alain Verleyen:

The problem is nobody talked about comparison operations, but about arithmetic operations. Feel the difference.

What possible arithmetic is happening in the ea thread to offset the cost of converting doubles to integers? Fernando gave the example of a price action ea...well let's use the daily pivot point for example. It would be foolish to first convert each price to int because in order to do so you'd have to divide three separate doubles by the step then call the round function for each one and then cast them all to int. Three. Separate. times. Remember that's just converting to integers, you still haven't calculated the pivot point. Would that be an optimised approach? No way! What you'd do is calculate the pivot point first as double, and then convert to static int for comparison. Except now you have to convert the bid to int so what you've really accomplished in this scenario is the exact opposite of optimisation. In this example your optimization is to not waste resources on int conversion at all! 
 
nicholishen:
What possible arithmetic is happening in the ea thread to offset the cost of converting doubles to integers? Fernando gave the example of a price action ea...well let's use the daily pivot point for example. It would be foolish to first convert each price to int because in order to do so you'd have to divide three separate doubles by the step then call the round function for each one and then cast them all to int. Three. Separate. times. Remember that's just converting to integers, you still haven't calculated the pivot point. Would that be an optimised approach? No way! What you'd do is calculate the pivot point first as double, and then convert to static int for comparison. Except now you have to convert the bid to int so what you've really accomplished in this scenario is the exact opposite of optimisation. In this example your optimization is to not waste resources on int conversion at all! 

What is your problem? Are you 6 years old and can't accept being wrong or something?

What is wrong with the Price Action example? Is it it somehow not acceptable? Is your EA example the only acceptable one, fit to be classified for your test results? Is any other person's EA example somehow inferior? Are you that egotistical?

I have coded a great deal of EAs, most of which are not price-action, and for the vast majority, integer arithmetic has greatly improved performance while live trading, each one to a varying degree obviously.

Backtesting is also part of EA design and also requires performance improvements, whether that be for pre-optimisation or for built-in self optimisation (which I use quite extensively).

As I stated before, an EA does not just take in quotes and output orders. EAs can get very complex in order to be useful for trading (not just as a coding example) and it can carry out a great number of necessary tasks.

So, please stop acting like a spoiled child and grow-up. Be the scientist that accepts when his findings did not fit the expected theory, and goes on to expand his understanding of the subject-matter.

 
Fernando Carreiro:

What is your problem? Are you 6 years old and can't accept being wrong or something?

What is wrong with the Price Action example? Is it it somehow not acceptable? Is your EA example the only acceptable one, fit to be classified for your test results? Is any other person's EA example somehow inferior? Are you that egotistical?

I have coded a great deal of EAs, most of which are not price-action, and for the vast majority, integer arithmetic has greatly improved performance while live trading, each one to a varying degree obviously.

Backtesting is also part of EA design and also requires performance improvements, whether that be for pre-optimisation or for built-in self optimisation (which I use quite extensively).

As I stated before, an EA does not just take in quotes and output orders. EAs can get very complex in order to be useful for trading (not just as a coding example) and it can carry out a great number of necessary tasks.

So, please stop acting like a spoiled child and grow-up. Be the scientist that accepts when his findings did not fit the expected theory, and goes on to expand his understanding of the subject-matter.

You'll have to forgive me if I kindly request that you to refrain from personal attacks. I haven't been disrespectful to you and called you names, so please extend the same respect to me.

There's a lot I could say in response to this, like how you've not produced a single repeatable example/test and literally all of your arguments are either ad hominem or subjective opinions... or maybe something about how the one code sample you posted actually proves my point instead of yours (hint: the double function runs faster on MT5 and no amount of extra loops can make the int version run faster than double)......

So I'll leave you with a question... 

In a straight up benchmark of <int> vs <double> (no conversions)...

template<typename T>
T Add(const T num1, const T num2)
{
   return num1+num2;
}

...with (1) arithmetic operation and (1) comparison operation...

if( Add(arrD1[i], arrD2[i]) > 2000. )

...why is <int> NOT faster than<double>?

<int>: 28 ms for 10000000 iterations
<double>: 23 ms for 10000000 iterations
#include <Arrays\ArrayInt.mqh>
#include <Arrays\ArrayDouble.mqh>
void OnStart()
{
//---
   srand(_RandomSeed);
   int iterations = (int)pow(10,7);
   CArrayDouble   arrD1;
   CArrayDouble   arrD2;
   CArrayInt      arrI1;
   CArrayInt      arrI2;
   arrD1.Reserve(iterations);
   arrI1.Reserve(iterations);
   arrD2.Reserve(iterations);
   arrI2.Reserve(iterations);
   
   for(int i=0;i<iterations;i++)
   {
      arrI1.Add(rand()%50000);
      arrI2.Add(rand()%50000);
   }
   for(int i=0;i<iterations;i++)
   {
      arrD1.Add((double)arrI1[i]);
      arrD2.Add((double)arrI2[i]);
   }
   
   ///TESTING INT
   long result=0;
   ulong m = GetMicrosecondCount();
   for(int i=0;i<iterations;i++)
      if(Add(arrI1[i], arrI2[i]) > 2000)
         result++;   
   m=GetMicrosecondCount()-m;
   m/=1000;
   printf("<int>: %d ms for %d iterations",m,iterations);
   printf("result = %d",result);
   
   ///TESTING DOUBLE
   result=0;
   m = GetMicrosecondCount();
   for(int i=0;i<iterations;i++)
      if(Add(arrD1[i], arrD2[i]) > 2000.)
         result++;   
   m=GetMicrosecondCount()-m;
   m/=1000;
   printf("<double>: %d ms for %d iterations",m,iterations);
   printf("result = %d",result);
   
}
//+------------------------------------------------------------------+

template<typename T>
T Add(const T num1, const T num2)
{
   return num1+num2;
}
 

To all involved on this thread, here is a short message and also some advice!

My blood is currently "boiling hot", and I may just start spurting out extremely vile language and breaking the forum rules. So, I am going to try to apply some self-control and abandon the discussion.

To those that may be following it, I now leave to you to decide for yourself and ask that you do your own testing and research and come to your own conclusions.

Regards,
Fernando

 
Fernando Carreiro:

To all involved on this thread, here is a short message and also some advice!

My blood is currently "boiling hot", and I may just start spurting out extremely vile language and breaking the forum rules. So, I am going to try to apply some self-control and abandon the discussion.

To those that may be following it, I now leave to you to decide for yourself and ask that you do your own testing and research and come to your own conclusions.

Regards,
Fernando


lol

 
Fernando Carreiro:

To all involved on this thread, here is a short message and also some advice!

My blood is currently "boiling hot", and I may just start spurting out extremely vile language and breaking the forum rules. So, I am going to try to apply some self-control and abandon the discussion.

To those that may be following it, I now leave to you to decide for yourself and ask that you do your own testing and research and come to your own conclusions.

Regards,
Fernando


Is your blood boiling because you just realized that you might have spent all that time doing int optimizations, and now MT5

bool(int_performance == double_performance) == true 

?

I mean, with these results, int conversion should actually be considered a de-optimization, am I right?

Is my code not a true apples to apples? If it's not please point out the error in my ways!

Reason: