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

 
Alain Verleyen:

That's not serious. I posted (and Fernando too) the code to run, the results, using arithmetic operations. Using int is way faster, and even more with mql5 than with mql4.

Can you admit that ? If not please say us what is wrong in the posted code.


Checking...


I did run Fernando's code and the <double> version was faster on MT5, not the int version! How do you explain that? How can you explain equal performance in a straight-up apples-to-apples benchmark using both arithmetic and comparison operations?????????????????????????????????? How?


You said arithmetic was faster with int, this test proves otherwise.

 
nicholishen:

I did run Fernando's code and the <double> version was faster on MT5, not the int version! How do you explain that? How can you explain equal performance in a straight-up apples-to-apples benchmark using both arithmetic and comparison operations?????????????????????????????????? How?


You said arithmetic was faster with int, this test proves otherwise.

I posted the results. You don't.

Please run the code I posted, it's a script, very easy, you just add it to a chart without any change, then you copy and paste the output from Experts log here. Should not be too hard.


As moderator I advice you to stop trolling. Next post which will be obviously just trolling will result in a ban. 

 
Alain Verleyen:

I posted the results. You don't.

Please run the code I posted, it's a script, very easy, you just add it to a chart without any change, then you copy and paste the output from Experts log here. Should not be too hard.


As moderator I advice you to stop trolling. Next post which will be obviously just trolling will result in a ban. 


This isn't trolling... I'm the only one posting evidence! wow.....just wow.

 
nicholishen:

This isn't trolling... I'm the only one posting evidence! wow.....just wow.


Where is this script?

 
Alain Verleyen:

That's not serious. I posted (and Fernando too) the code to run, the results, using arithmetic operations. Using int is way faster, and even more with mql5 than with mql4.

Can you admit that ? If not please say us what is wrong in the posted code.


Checking...

That's because the compiler optimized your code. You didn't use the result of the addition so it was removed from the test. Also you need to run enough iterations to have significant time results.

Results from the code you posted (just 10 times more iterations).

2018.01.15 10:34:59.100 224626_2 (EURUSD,M1) <int>: 14638 ms for 100000000 iterations

2018.01.15 10:35:15.514 224626_2 (EURUSD,M1) <double>: 16379 ms for 100000000 iterations

After modifying to avoid compiler optimization.

2018.01.15 10:43:44.698 224626_2 (EURUSD,M1) <int>: 3164 ms for 100000000 iterations

2018.01.15 10:43:44.702 224626_2 (EURUSD,M1) result = 99813497 sum=3276606316406

2018.01.15 10:44:24.734 224626_2 (EURUSD,M1) <double>: 40028 ms for 100000000 iterations

2018.01.15 10:44:24.736 224626_2 (EURUSD,M1) result = 99813497 sum=3276606316406.000000


Files:
224626_2.mq5  3 kb
 
nicholishen:

Where is this script?

Attached, again.
nicholishen:

This isn't trolling... I'm the only one posting evidence! wow.....just wow.

Yes "wow". I am curious to see what you will say at the end.

Files:
224626.mq5  4 kb
 
Alain Verleyen:
Attached, again.

Yes "wow". I am curious to see what you will say at the end.


This script is not relevant to our discussion, that's an apples-to-oranges comparison. In order to prove that int arithmetic is faster than double arithmetic you need to be using the same operators for the same number of iterations. Like I already have.

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

This script is not relevant to our discussion, that's an apples-to-oranges comparison. In order to prove that int arithmetic is faster than double arithmetic you need to be using the same operators for the same number of iterations. Like I already have.

Still waiting the results.

 
Alain Verleyen:

Still waiting the results.


Seriously? It runs in milliseconds. Maybe it's time for a processor upgrade! ;) lol

 
Alain Verleyen:
Attached, again.

Yes "wow". I am curious to see what you will say at the end.


By the way, the script you posted isn't a fair comparison because the int+=iterator gets optimized by the compiler so the loop is not going through every iteration, instead it's performing the maths (that why it's quicker). That's why you need a random data-set for testing and you need to run a comparison on the result, log it, and have a final use for the result variable to ensure that your results aren't biased by using compiler tricks!

Reason: