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

 

nicholishen:

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!

Yes, so you could have fixed that yourself and see that it doesn't change the results significantly. And anyway it's exactly what I did with your script.

Alain Verleyen:

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).

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

Any serious comment on these results ?

 
Alain Verleyen:

Yes, so you could have fixed that yourself and see that it doesn't change the results significantly. And anyway it's exactly what I did with your script.

Any serious comment on these results ?


Yes, you can't possibly reconcile in your mind how my apples-to-apples benchmark proves that there is no performance gain with integer arithmetic in MQL5. So in a desperate attempt to win a straw-man argument you are changing the subject and trying to prove your point with a compiler trick. We both know that means nothing when it comes to real optimization with random data. Have fun converting all your double to ints and back, for nothing :)

 

https://en.wikipedia.org/wiki/Loop_optimization - link to wikipedia. Loop optimization.

 
nicholishen:

Yes, you can't possibly reconcile in your mind how my apples-to-apples benchmark proves that there is no performance gain with integer arithmetic in MQL5. So in a desperate attempt to win a straw-man argument you are changing the subject and trying to prove your point with a compiler trick. We both know that means nothing when it comes to real optimization with random data. Have fun converting all your double to ints and back, for nothing :)

This is just pathetic.

 

nicholishen:

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!

Yes, so you could have fixed that yourself and see that it changes nothing significantly. And anyway it's exactly what I did with your script.

You are so arrogant that you can't even imagine you are wrong, that's a psychological school case. It's pitiful

I really hope you will learn something today.


This post you can consider it as ad personam. Unfortunately there is no other way to stop you, don't forget this topic will remain public forever. 

nicholishen:

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

Banned 1 week for repeated trolling. I wasted enough time with you.
 
nicholishen:

Yes.

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

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

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



I ran script, why is integer and double same performance? Anyones?

 
SanjayBalraj: I ran script, why is integer and double same performance? Anyones?

Integer operations are done in the CPU. Floating point operations are done in the FPU and the CPU does a few instructions in parallel.

 
whroeder1:

Floating point has infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
          Double-precision floating-point format - Wikipedia, the free encyclopedia

See also The == operand. - MQL4 and MetaTrader 4 - MQL4 programming forum

Stop worrying about it and just format it when printing.


Yeah. The comparison is well-done, the way I print it to check if so, no... possible also.

 
whroeder1:

Integer operations are done in the CPU. Floating point operations are done in the FPU and the CPU does a few instructions in parallel.


Bless you Mr. Whroeder1, and thank you for your answers full of wisdom. May I ask, why does nicholishen benchmark run same performance for integer and double if two different process? I run his script 

https://www.mql5.com/en/forum/224626/page7#comment_6344294

double variable with wrong decimal cases
double variable with wrong decimal cases
  • 2018.01.15
  • www.mql5.com
Hi, I'm runnng this code to increase the lotsize in steps: What I get is this result: 2018.01.12 17:15:58...
 
SanjayBalraj:

Bless you Mr. Whroeder1, and thank you for your answers full of wisdom. May I ask, why does nicholishen benchmark run same performance for integer and double if two different process? I run his script 

https://www.mql5.com/en/forum/224626/page7#comment_6344294

@nicholishen 

So it's more complex than we thought. It depends of the hardware and the exact tests run. 

Anyway for the way you lead this discussion you deserve your ban.

Reason: