You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thanks for not answering to my question
It happens :-)
I don't see the difference either. The compiler should optimize the expression.
I don't get your point about "10 times faster". What exactly is 10 times faster than what...exactly ?
I don't want to search. I want your detailed answer. loool
I don't want to search. I want your detailed answer. loool
OK, here is a very simple example. I hope this is enough research on my side to cover your need of details on unconditional code.
These are my results on my tablet...
IF IF Loop time: 5 nanosec; total time: 84024 microsec
IF ELSE IF Loop time: 2 nanosec; total time: 89009 microsec
IF ELSE Loop time: 1 nanosec; total time: 84006 microsec
Unconcditional Loop time: 0 nanosec; total time: 39527 microsec
Noticable is the time difference given for each loop run, as well as the distribution of execution total compared to single runs. Although this is not a precise measurement, by the nature of statistics, this should be correct.
OK, here is a very simple example. I hope this is enough research on my side to cover your need of details on unconditional code.
These are my results on my tablet...
IF IF Loop time: 5 nanosec; total time: 84024 microsec
IF ELSE IF Loop time: 2 nanosec; total time: 89009 microsec
IF ELSE Loop time: 1 nanosec; total time: 84006 microsec
Unconcditional Loop time: 0 nanosec; total time: 39527 microsec
Noticable is the time difference given for each loop run, as well as the distribution of execution total compared to single runs. Although this is not a precise measurement, by the nature of statistics, this should be correct.
Ok so as I suspected it's far from 10 times. More around 2 times ;-)
There are two small bugs in your code :
1. your forgot to reset loop_cnt (unless you did it on purpose ? but why).
2. It should be
right_ptr += !eval;
And here is a more then 20 times faster solution for this specific example.
2021.07.10 15:30:34.586 372818 (EURUSD,M1) Unconcditional Loop time: 1.9 nanosec; total time: 31187 microsec. Left = 1606418432 Right = 532676575
2021.07.10 15:30:34.659 372818 (EURUSD,M1) IF IF Loop time: 3.9 nanosec; total time: 66114 microsec. Left = 1606418432 Right = 532676575
2021.07.10 15:30:34.734 372818 (EURUSD,M1) IF ELSE IF Loop time: 4.1 nanosec; total time: 68087 microsec. Left = 1606418432 Right = 532676575
2021.07.10 15:30:34.809 372818 (EURUSD,M1) IF ELSE Loop time: 4.0 nanosec; total time: 67479 microsec. Left = 1606418432 Right = 532676575
2021.07.10 15:30:34.830 372818 (EURUSD,M1) TERNARY ? Loop time: 0.2 nanosec; total time: 3015 microsec. Left = 1606418432 Right = 532676575
I fixed the bugs and added quick checking of the solutions.
Thanks for your time it was funny.
Ohh, I am sorry... - I messed up the measurement in the code. I have attached a file with some other measurements and corrected loop_cnt value.
Thank you.
Ok so as I suspected it's far from 10 times. More around 2 times ;-)
There are twosmall bugs in your code :
1. your forgot to reset loop_cnt (unless you did it on purpose ? but why).
2. It should be
right_ptr += !eval;
And here is a more then 20 times faster solution for this specific example.
2021.07.10 15:30:34.586 372818 (EURUSD,M1) Unconcditional Loop time: 1.9 nanosec; total time: 31187 microsec. Left = 1606418432 Right = 532676575
2021.07.10 15:30:34.659 372818 (EURUSD,M1) IF IF Loop time: 3.9 nanosec; total time: 66114 microsec. Left = 1606418432 Right = 532676575
2021.07.10 15:30:34.734 372818 (EURUSD,M1) IF ELSE IF Loop time: 4.1 nanosec; total time: 68087 microsec. Left = 1606418432 Right = 532676575
2021.07.10 15:30:34.809 372818 (EURUSD,M1) IF ELSE Loop time: 4.0 nanosec; total time: 67479 microsec. Left = 1606418432 Right = 532676575
2021.07.10 15:30:34.830 372818 (EURUSD,M1) TERNARY ? Loop time: 0.2 nanosec; total time: 3015 microsec. Left = 1606418432 Right = 532676575
I fixed the bugs and added quick checking of the solutions.
Thanks for your time it was funny.
Yes, exactly. The ternary operator is the unbeaten champ.