Algorithms, solution methods, comparison of their performance - page 6

 
Alexandr Andreev:

What's wrong with a regular array of ints? Why the thongs....

Because we don't know in advance how many trades the EA will make. We need to allocate memory for the array in advance, but we don't know how much.

So we had to find a solution that is fast and short and doesn't take up unnecessary memory.

 
Реter Konow:

Not really.

...

Once again, you don't understand what we are talking about. The trade number is assigned by the trading system (MetaTrader or exchange). By the deal number is meant not the serial number of the deal, but precisely the ticket returned by theHistoryDealGetTicket function. So, take this into account and modify your example.
 
Alexandr Andreev:

Again, imagine that instead of string you use a class to store a dynamic array of charts - and you think this is fast?

I don't know the inner workings of string functions, but function speed measurements show that it takes less than 100 microseconds to find and return a medjic from a string of thousands of medjics.

That seems very fast to me. It is unlikely to be faster.

 
Реter Konow:

Because we don't know in advance how many trades the EA will make. We need to allocate memory for the array in advance, but we don't know how much.

That's why we had to find a solution that is fast and short and does not take up unnecessary memory.

About fast. Measure the extraction speed of all 24000 thousand medjics. You will be unpleasantly surprised.

 
Реter Konow:

Done:

Your example can no longer be fixed :)

What happens if you don't have enough row size?

Your example may have 32767 records(transactions), so try to compare the last written and read magik.


 
Vasiliy Sokolov:
Once again, you don't understand what we are talking about. The trading system (MetaTrader or exchange) assigns a trade number. By the deal number it means not the serial number of the deal, but precisely the ticket, returned by theHistoryDealGetTicket function. So, taking this into account and modify your example.

It's not a problem. Tomorrow I will make a second version that will work with the ticket.

This variant is also convenient in trading.

 
Vasiliy Sokolov:

On the fast count. Measure the retrieval speed of all 24,000,000 medjiks. You'd be unpleasantly surprised.

Well, at any given moment, we only need one medjic, right?

Extract a medjack, access any information related to the order.

Why do we need to extract 24,000 medjiks at once?

 

What the hell am I doing here!? Who am I wasting my time with? I'd better go and have a stronger drink.

p.s. Oh, yes, you have one more mistake. If MathRand on the third call returns e.g. number 1000 and writes _3_1000_, what kind of a medjic will be found for a deal with ordinal number 1000?
 
Yury Kulikov:

Your example can't be fixed now :)

What happens if you don't have enough row size?

Your example may have 32767 records(transactions), so try to compare the last written and read magik.


Thanks for pointing out the line length limit.

You can start writing the second line. Then the third and so on... :)

 
Реter Konow:

I don't know the internal implementation of string functions, but a function runtime measurement shows that it takes less than 100 microseconds to find and return a medjic from a total string of thousands of medjics.

I think it's very fast. I don't think it could be any faster.


well, in a nutshell a string of one character is achar with some code from 0 to 255 and weighs 1 byte... and it's allocated just enough memory to fit 256 values, 257 won't fit there, it will switch back to the first one.

In any page, every character is a number from 0 to 255... so we take the number 10000000 - it weighs 4 bytes, convert it to the string "10000000" then for each character we allocate memory as for a individual chart from 0 to 255... 8 bytes total. There's no memory saving anywhere.