My approach. The core is the engine. - page 84

 
Maxim Kuznetsov:

And yes, parsing texts in MQL is a lot of fun :-) Well, it's not designed for text parsing. I mean, you can, but it's a bummer...

Arrays and orders - that's what MQL is all about

That's what I'm talking about... :)

 
Nikolai Semko:

Versatility is often synonymous with sluggishness, and even more so with string.
Let me give you one example.

I once parsed a string received from a crypto-exchange using WebRequest. And I parsed it usingSergeev's JSON library, which he ported from "high-speed C++ library". And I've noticed that the speed is very unsatisfactory. There everything was done through "universal" strings.

I understood that the reason for the low speed was stringing and wanted to avoid using string-functions and wrote a function parsing directly from the uchar array. The result surprised me quite a bit. My parsing speed was.... (drum roll) 800 times faster. If parsing an entire string through JSON took 0.3 seconds, my function parsed it in less than half of a millisecond.

Here is an example of my parsing via uchar array.

The gist of your suggestion is as follows:

  1. We take a string (640 characters), send it to StringToChar() function;
  2. We get the array and store it in the resource.
  3. Get the content of the resource on the second side using ResourceReadImage() to the second array.
  4. Send the second array to CharArrayToString() and get the final string.
  5. Next, split the string by a delimiter and write the parameter values to the kernel.

I originally wanted to use MT objects to transfer strings.

  1. We take a string (640 characters), and split it into parts of 64 characters each.
  2. We do a loop on the communication objects and write the parts of the string in their description.
  3. On the second side, do a loop on the communication objects, get parts of the string and each part is split by a delimiter, extracting the parameter number and value.
  4. We write parameter values to the kernel.

The second variant seemed faster to me initially.

When you have so many tasks like I have, you have to rely on your intuition when choosing a solution. You won't have enough life to check everything thoroughly. You either need a team or a great sense of intuition in choosing the right direction. And of course, you have to sacrifice professionalism and put up with gaps in knowledge. Otherwise, you will be left to make doodles (albeit professionally) and will never finish a mega-project. This is reality.

 
Реter Konow:

The gist of your suggestion is as follows:

  1. We take a string (640 characters), send it to StringToChar();
  2. We get an array and store it in a resource.
  3. Get the content of the resource on the second side using ResourceReadImage() to the second array.
  4. Send the second array to CharArrayToString() and get the final string.
  5. Next, split the string by separator and write parameter values to the kernel.

Not at all like this.
I'm busy at the moment - no time to explain.

If you take apart my code in detail, so that no blank spots are left, you will make a lot of discoveries for yourself.
ZS. Only without a debugger it will be much harder to figure it out. I don't know if you started to use it or you still don't use this important tool.

 
Nikolai Semko:

...

If you examine my code in detail, and do not leave blank spots, you will make a lot of new discoveries.
ZS. Only without using debugger it will be much more difficult to understand. I don't know if you started using it or you still don't use this important tool.

I'll have a closer look at your code tomorrow. (Don't forget about time zones).

Maybe indeed, I'll discover something new. ))

 

Any structure is a string. An array of structures is an array of strings with a description of their format. Class - structure and methods, class implementation - array of implementations (pardon my French).

You don't need to convert anything until the last moment. There are only strings involved everywhere. Simply, they are normalized: some take 2, or 4 bytes, and some take 1, so you have to align.

I first used this approach around 1993, Clarion DBMS. It worked very quickly.

 
Алексей Тарабанов:

Any structure is a string. An array of structures is an array of strings with a description of their format. Class - structure and methods, class implementation - array of implementations (pardon my French).

You don't need to convert anything until the last moment. There are only strings involved everywhere. Simply, they are normalized: some take 2, or 4 bytes, and some take 1, so you have to align.

I first used this approach around 1993, Clarion DBMS. It all worked very quickly.

About the same time with the same :-) One school... by the way the DBMS wasn't bad and was ahead of its time in many ways.

PS/ there's a hotly beloved tickle at times, a posteriori at the "everything is a string/text" concept level. The speed is really on the level of python.

 
Реter Konow:

I'll take a closer look at your code tomorrow. (Don't forget about time zones).

Maybe I'll really discover something new. ))

May be it will be useful

The example of indicator that uses resource variable on double example, which does not reinitialize its value when changing TF. This is a more convenient alternative to global variables of the terminal. In the same way different data structures and arrays of these structures can be used as global ones.

Files:
 
Nikolai Semko:

it might still come in handy.

)

 
Реter Konow:
For the sake of interest, I will try the variant with union. And withCharArrayToString and StringToCharArray. Although my intuition tells me that it will hardly be faster than communication via description of МТ objects. But I may be wrong. Let's see...

Peter, you made a wild card from the beginning, and now you're arguing about messaging performance within your wild card. You get it: a string is just a handy ***, nothing more. Any data is really just a collection of bytes in memory. So you are advised to handle bytes directly, but you are stubborn as always not understanding that the same string is the same byte array. So you don't lose anything on string conversion to uchar array. But when parsing a string, your performance really slows down. That's why all your intuition is just missing.

 
Vasiliy Sokolov:

1. Peter, you originally did a game, and now you're arguing about messaging performance within your game.

2.You understand: a string is just a handy ***, nothing more. Any data is really just a collection of bytes in memory. So, they advise you to work with bytes directly, but you are stubborn as always not understanding that the same string is the same byte array. So you don't lose anything on string to uchar array conversion. But when you parse a string, your performance really slows down.

3. So all your intuition is just a miss.

1. "Wildness" - in this case, it's your understanding, not what I did. It took 75 pages for you to understand what it's about and what the engine is about. Understand: Flaws and errors do not characterise an entity. No form of essence characterizes the essence itself. Just like your clothes don't define what kind of person you are. Only wrong thinking judges the whole by the particular.

2. It's clear to me as it is. I will check today if there will be a real speed gain using the StringToChar function.

3. Every day I check my intuition. I doubt it every day. And rightly so. If it fails, you should be guided by Reason. But Reason is too limited, arrogant and stupid to always be relied upon. Therefore, intuition is the only alternative. If you know what I mean...

Reason: