Errors, bugs, questions - page 2878
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
which conversion variant will work faster during optimisation
This will only be called once per pass. Therefore, it makes no difference.
This will only be called once for the entire passage. So it makes no difference.
so yeah... But I'm going to run it for a couple of days for optimization, I want to measure the performance in some way ..... although I suspect variant 1 will be more efficient, there won't be 100500 times of copying into arrays
yes... But I'm going to run the computer for a couple of days to optimise it, I want to measure the performance in some way ..... although I suspect option 1 will be more efficient, there won't be 100500 times of copying to arrays
union is not copying to arrays, it's different interpretation of the same memory space. so the 2nd option is probably faster, but as noted above, it doesn't matter.
yes... But I'm going to run the computer for a couple of days to optimise it, I want to measure the performance in some way ..... although I suspect option 1 will be more efficient, there won't be 100500 times of copying to arrays
there's an old way to measure speed
in the style of
for (int i=0; i< 1000000; i++) {our code1}....
for (int i=0; i< 1000000; i++) {our code2}....
Union is not as fast as it sounds. I bet on the first one.
I bet on the first one too! Binary operators are several times faster than the if operator, although the second one does not have it.
checked:
2020.10.15 21:48:01.401 SpeedTst (EURUSD,H1) tst 1 : : loops=10000000000 ms=10864370
2020.10.15 21:48:12.264 SpeedTst (EURUSD,H1) tst 2 : : loops=10000000000 ms=10862287
the difference is not significant, it is highly probable that if we switch the tests in the opposite order, the results will be the opposite
not critical
not a significant difference, it is highly probable that if you swap the tests, the results will be the opposite
It is highly probable that the compiler has generated the same code for both cases. In this case, just choose the one you subjectively like better
checked:
2020.10.15 21:48:01.401 SpeedTst (EURUSD,H1) tst 1 : : loops=10000000000 ms=10864370
2020.10.15 21:48:12.264 SpeedTst (EURUSD,H1) tst 2 : : loops=10000000000 ms=10862287
the difference is not significant, it is highly probable that if we switch the tests in the opposite order, the results will be the opposite
not critical
The script here demonstrates that the time of random number creation may be non-uniform and depends on the volume of created variables)))
And the code we need in this number of repetitions takes me 0 ms.
Still no answer.
or the code optimiser is cutting out something unnecessaryThere seems to be a script that demonstrates that random number generation times can be unequal
no rand() is a normal function, it always works the same
But when testing speed, if you initialize it with constants, the tests will "speed up" during execution - code optimization in MQL during runtime is good
in general, it was checked many times
and a lot depends on the size of created variables)))
of course, allocating memory is time consuming, I checked it, I'm testing both dynamically created objects ( new pointer ) and just objects in local scope, the test stretches 100500 times per new + delete
the whole question was, because in the tester in global scope memory is allocated to variables once and not every pass - but I need arrays uint, so I tested with this script, not as I wrote it the first time
And the code we need in this number of repetitions takes me 0 ms
still no answer
Either the code optimiser is cutting something unnecessary.did you use my script? - either you didn't wait till the end of the test and interrupted or you overflowed ulong - the first macro parameter is 10^ count
it is highly probable that the compiler has generated the same code for both cases. in this case, just choose the one you subjectively like best.
yes, maybe so
that's what I was asking - I've read many times that modern processors can execute more than one elementary operation per clock by optimizing the instruction pipeline .... a lot of blah-blah-blah... and the point is that the arithmetic instructions are executed by the processor in an unpredictable number of clock cycles
As for branching and memory allocation operations, they are very badly optimized by the processor, so don't look for optimization in simplifying arithmetic, try to write maximally linear code with minimum branching, and variables are better declared and assigned values right before calculations, that allows instruction pipeline and cache sampling prediction to optimize this code
I.e. sampling values of elements in the array (addressing) most likely won't be crucial for speed - I thought there would be a shift advantage vs. union, it turns out there is no difference at all