Features of the mql5 language, subtleties and tricks - page 102

 
Alexey Navoykov:

First of all, it goes through the message queue. Secondly, you have to do some additional conversions (back and forth). Plus there's some validation going on.

By the way, you should not specify the size of the structure explicitly. There is sizeof for it.

  • Where did you see a message queue there?
  • There are no round-trip conversions. The same union is used as in @fxsaber example
  • There is no validation either.
  • Of course, you could use sizeof(...) , but since it was an implementation of a specific task and not a universal one, I just had to write it shorter as 3 digits.

Perhaps you looked at some other code.

The only thing I don't like about my version: I had to double the line size to bypass zeros, because zero is perceived as the end of the line. I feel in my spinal cord that there is a simpler solution, but I haven't found it. But it still works faster.

 
Nikolai Semko:

  • Where did you see the message queue?

SetWindowText/GetWindowText are not sent through messages?


There are no round-trip conversions.

Of course they do. And what is all this dancing with tambourines:

for(int i=0; i<56; i++) if(U.a[i]==0) m[2*i+1]=2; else m[2*i]=U.a[i];
 
Alexey Navoykov:

SetWindowText/GetWindowText are not sent through messages?

And you're talking about Windows messages ... So what? Is there a faster alternative to exchange data between different windows programs without self-written dll?

I understand that you were offended by my words, that my version is fast. Well, firstly, I did not assert it, but only assumed. Secondly, I backed up my assumption with testing code by comparing it withMemory Mapping.
And if you're trying to refute even an assumption, please don't base your refutation only on declarative statements. I will be very grateful if you can dissuade me and point to a faster implementation of data exchange between terminals without any self-written dll.

I don't exclude that the variant via RAM disk will be much faster. But this is a little different topic, because it requires installation of RAM disk and its configuration.

Alexey Navoykov:

Of course. What's this dancing with tambourines:

for(int i=0; i<56; i++) if(U.a[i]==0) m[2*i+1]=2; else m[2*i]=U.a[i];

So much for tambourines. This is trivial. And this triviality, by the way, is carried out in 50-60 ns, when all block of receiving of tick structure is carried out in 90 µs (90 000 ns.), i.e. these "diamonds" occupy only 0.06 % of time of receiving of data block. Moreover, I wrote, that this point confuses me only in view of memory doubling.

And so my version seems very comfortable, simple and fast for exchange of small data structures.

 
Nikolai Semko:

  • The only thing I don't like about my version: I had to double the line size to bypass the zeros, because the zero is perceived as the end of the line. In my backbrain I feel that there is a simpler solution, but I have not found it. But it still works faster.

Forum on trading, automated trading systems & strategy testing

Libraries: HistoryTicks

Automated-Trading, 2018.03.29 11:09

  • There are cross-platform functions in the sources (Data_String.mqh file) that allow you to put/extract any data to/from a string. For example, it allows to easily exchange any data between any MQL-programs using string-parameter (sparam)of user events;
#include <fxsaber\HistoryTicks\Data_String.mqh> // https://www.mql5.com/ru/code/20298

void OnStart()
{
  MqlTick Tick;
  
  if (SymbolInfoTick(_Symbol, Tick))
  {
    const string Str = DATA_STRING::ToString(Tick);
    
    MqlTick Ticks[1];
    
    Ticks[0] = DATA_STRING::FromString<MqlTick>(Str);
    ArrayPrint(Ticks);
  }
}
 
fxsaber:

Wow!
I didn't even know about functions like CryptEncode andCryptDecode. Thanks!
I will look into it.
But while at first sight it seems to be high-tech, but madly slow, because CryptEncode function runs two orders of magnitude slower (microseconds vs. tens of nanoseconds) than what was called here tambourines:

for(int i=0; i<56; i++) if(U.a[i]==0) m[2*i+1]=2; else m[2*i]=U.a[i];
 
Nikolai Semko:

I take it that you were offended by my saying that my version is fast. Well, firstly, I didn't claim that, I just made an assumption. Secondly, I backed up my assumption with testing code when comparing it withMemory Mapping.

I wasn't speaking about "speed" but about"it may be faster than all existing solutions", so I made several remarks without any attacks. And those remarks were quite fair. But you, for some reason, first stubbornly deny it ("perhaps you looked at some other code") and then get into position "so what! Solet's separate flies from cutlets.

Firstly, my message was written before you've cited your testing code. Secondly, regarding MemoryMapping (more exactly, the mentioned MQL-wrapper), I've never claimed it's fast. Moreover, in discussion thread on this project here I've pointed out the author's bugs that create lags and how to fix them. So if you're going to test something, then test it in its native form, not in the form of someone else's wrong solutions.

 
Nikolai Semko:

But while at first glance it all, of course, high-tech, but insanely slow, because the CryptEncode function is two orders of magnitude slower (microseconds vs. tens of nanoseconds) than what is called here tambourines:

What do you need speed for?

 
Alexey Navoykov:

I'm not talking about "speed", but about"it may be faster than all existing solutions". So I made some remarks, without any attacks. And these remarks were quite fair. Only you for some reason first stubbornly deny it ("probably you looked at some other code"), and then you get into the position "so what! Solet's separate the flies from the cutlets.

Firstly, my post was written before you've cited your testing code. Secondly, regarding MemoryMapping (more exactly, its MQL-wrapper mentioned), I've never claimed it's fast. Moreover, in discussion thread on this project here I've pointed out the author's bugs that create lags and how to fix them. So if you're going to test something, test it in native form, not someone else's wrong decisions.

Ok. Agreed. I said it too loudly.

I just wanted to say, that possibly using user32.dll instead of kernel32.dll may be faster in the matter of connecting two terminals via WinAPI, because all implementations I've found exactly used kernel32.dll.

 
fxsaber:

What is the speed for?

I'm sorry, I do not understand the question.
You're asking - why do you need the bridge speed between terminals?

 
Nikolai Semko:

I'm sorry, I don't understand the question.
You're asking - why do you need the speed of the bridge data exchange between terminals?

Yes.

Forum on trading, automated trading systems and trading strategies testing

Peculiarities of mql5 language, tips and tricks

Semko, 2018.09.21 13:20

But while at first glance, of course, it's all high-tech, but insanely slow, because CryptEncode function is executed two orders of magnitude slower(microseconds vs. tens of nanoseconds) than what is called here tambourines:

Reason: