Questions about MQL4 - page 12

 
the only question is, будет ли работать заметно быстрее, если обработку массивов вынести в DLL?
does anyone have any compiler installed? please check! isn't it that boring?


Array accesses are ten times slower than local variables.


The time of addressing an array item is ALWAYS not longer than the time of addressing a variable.
The specific figures will be different for different compilers, but the tendency should remain the same.

The compiler is Visual Studio 2005. The processor is Athlon XP 2500+.
Execution time together with array initialization is 1.06-1.07 sec.
Dim t1, t2 As Double t1 = DateAndTime.Timer() Dim x, y, z As Double Dim d, k As Double Dim Open(5001), Close(5001) As Double For d = 5000 To 1 Step -1 For k = 1 To 4999 z = Close(k) : y = Close(k + 1) : x = Close(k + 2) z = Open(k) : y = Open(k + 1) : x = Open(k + 2) Next Next t2 = DateAndTime.Timer() MsgBox(CStr(t2 - t1) + " seconds")



The same loop, but with

z = Close(1) : y = Close(1) : x = Close(1) z = Open(1) : y = Open(1) : x = Open(1)


gives 0.37 to 0.4 seconds.

And finally,

z = k : y = k : x = k z = k : y = k : x = k


0,56-0,6 с.

So I would like to draw the following conclusion:
is not about a compiler and not about "array/non-array", but about proper data structuring and correct code!
P.S. Of course, all the above theses, except for time measurements, are my personal, deeply subjective and modest opinion, just as a programmer.

 
thank you!

yes, the optimization of resulting code in compiler is a power after all...
I don't want to get into details, but it seems that visual studio copiler optimizes array accesses by itself.
to make the test fair, you need to enter a variable, say, S; and insert between all x,y,z assignments something like S=S+x, S=S+y, S=S+z, and then output S besides time to get "pure" speed.

though the compiler optimizer can partially figure out this cheat... :)
 
to ensure the integrity of the test, we need to introduce a variable


I have long ago dismissed such thoughts. I've even done tests. And I've come to a conclusion:

The compiler performs all the prescribed operations and simply has no right not to perform them because it's simply impossible to know 100% from where I plan to access these variables - in the same method, from some timer (and structurally unrelated code) or even from some other process.
So, everything is fair. Checked.

P.S. Offtopics, sorry. Couldn't resist.
 
about array accesses...
what is the array specified by the parameter in ArrayCopySeries?

is it a regular array of values, or an array of pointers to values?

(this is obviously a dumb question, but I haven't programmed in 10 years, much less in C, much less on Windows.)

and where to read about all this?
 
Is there any way to determine the state of the EA trigger between ticks?
I really need...

Is there any way to... I don't know. Is recursive invocation of start() allowed?
 
so isn't deinit() triggered when the button is switched off?
 
Is there any way to determine the state of the EA's enable button between ticks? <br / translate="no">

there is no way. the EA will not start if the button is disabled.

Is recursive access to start() allowed?

is allowed.
 
Slawa,
Thank you for your reply.


Well, uh... So what now...?
I don't know... or go for 5, but yesterday... and today for 3... the small ones.

I'll have to settle for a lot of small ones. I didn't want to. Well, what now... :(
It seems so easy...

(don't mind me, it's meditation already splashing over the keyboard)
 
FirstVisibleBar() and BarsPerWindow() are not highlighted in colour in ME.
Is it just me, or is it supposed to be?
 
FirstVisibleBar() and BarsPerWindow() are not highlighted in colour in ME. <br / translate="no"> Is it just me or should it be?

They are and always have been highlighted normally. Just checked the 183 build and the 187.