DLLs and passing control - page 2

 
alladir:

Ok thanks, but I will try a few more things to see if I can reduce dropped ticks a bit.

Just testing some things I found something surprising. This little script takes 10 whole seconds to do the 9999 iterations

I realise an average 1ms per iteration is nothing really but the dll does more operations and takes 0.5 secs to do 1,000,000 iterations.

Are you comparing like with like ? does C++ have StringConcatenate() and DoubleToStr() functions ?
 

Yes the C++ code stores the string in memory

logs[index] = logs[index]+minute+','+second+','+millisecond+','+bid+','+ask+','+vol+'\n';

but that's after a few checks to see if it's really a new tick and checking if it's a new hour. The values are turned to strings with stringstream.

Maybe running the dll repeatedly in the same start function reduces some kind of dll 'calling' time..?

 
alladir:

Yes the C++ code stores the string in memory

but that's after a few checks to see if it's really a new tick and checking if it's a new hour. The values are turned to strings with stringstream.

Maybe running the dll repeatedly in the same start function reduces some kind of dll 'calling' time..?

So your DLL code is different . . . no suprise that it may be quicker then.
 
RaptorUK:
So your DLL code is different . . . no suprise that it may be quicker then.

I'm still surprised! An external dll can do the same things and more in a 2000th of the time it takes mql!
 
alladir:
I'm still surprised! An external dll can do the same things and more in a 2000th of the time it takes mql!
Maybe StringConcatenate() and DoubleToStr() are really, really slow . . .
 
RaptorUK:
Maybe StringConcatenate() and DoubleToStr() are really, really slow . . .


That seems to be it. + is faster than StringConcatenate with just 2 or 3 strings to be joined, but not more. Using + in that script doubles the time taken.

So it seems I've got the highest granularity (??) without skipping MT4 altogether.

 
Try to test duration of a loop with a dummy DLL call. It used to be slow. They might have fixed it, but I doubt.
 

Ohhh, I see my mistake now, the Volume was fixed in the loop calling the dll, so i wasn't processing all those ticks.

Actually 10000 iterations takes 1 second, which is still 10 times faster than StringConcatenate, but much slower than writing straight to file

Still, well done to MQ if they did take effort to improve the speed of calling the DLL

So yes, for anyone actually reading this... the fastest way to get ticks seems to be use FileOpen in Init, FileWrite in Start and FileClose in Deinit

And if you know how to let MT4 retain control after calling a dll function, let me know

 

meh. despite all the speed tests, the DLL is still picking up more ticks. I tested side by side with just writing the values straight to file.

Strangely... the ticks missed writing straight to file came BEFORE a very short gap, not AFTER. I assumed ticks were missed because the Start function was running when it arrived.. but seemingly not. Unless the volume number is not a unique indicator for each tick.

 
alladir:

meh. despite all the speed tests, the DLL is still picking up more ticks. I tested side by side with just writing the values straight to file.

Strangely... the ticks missed writing straight to file came BEFORE a very short gap, not AFTER. I assumed ticks were missed because the Start function was running when it arrived.. but seemingly not. Unless the volume number is not a unique indicator for each tick.

Something doesn't look right in the timings . . . for example ticks 35 & 36 have the same time from the DLL but different seconds in the FileWrite
Reason: