MT5 and speed in action - page 52

 

Re-engineered for a macro

#define  µsSLEEP(µsRange)                              \
        {                                             \
           ulong c = GetMicrosecondCount() + µsRange; \ 
           while(GetMicrosecondCount() < c);          \
        }


//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   while(!_StopFlag)
   {
      µsSLEEP(5000000);
      Print("Прошло 5000000 микросекунд");
   }
}
 
Roman:

Of course, it can do more than just one core.

I meant while without Sleep.

It's clear that slip is not suitable here because we need micro-seconds. But it will be humming without it...

 
Andrey Khatimlianskii:

I meant while without Sleep.

It's clear that slip won't work here because we need micro-seconds. But it will hum without it.

Of course, it hums without a slip.
TheGetMicrosecondCount counter is running

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   ulong µs = 0;
   
   while(!_StopFlag)
   {
      µs = GetMicrosecondCount();
      
      Comment((string)µs);
      ChartRedraw();      
   }
   
   Comment("");   
}
 
Roman:

Of course it's spinning without a slip.
The GetMicrosecondCount counter is running.

It's not just the counter that is loaded. An empty infinite loop will load it too. That's what I mean.

Bad solution, in general. But I will not suggest it better.

 
Andrey Khatimlianskii:

It's not just the counter that is loaded. An empty endless loop will also load. That's what I mean.

It's a bad solution, all in all. But I won't suggest it better.

So an empty loop will obviously draw the full potential of the processor's clock cycles.
I don't understand the complaint about a bad solution. If it's not suitable for your resources, it doesn't mean it's bad.
µsSLEEP gives you loop latency less than standard Sleep(1); i.e. in microseconds, not milliseconds.
The 5000000 in the examples above is just for an example, the real frequency in combat would be less than 1 ms

I don't understand your problem.
Do
you need it to be free of stress?
Put a regular Sleep(20); in milliseconds

 
Roman:

So empty while understandably picks up the full potential of the processor clock cycles.
I don't understand the complaint about a bad solution. If it doesn't suit your resources, it doesn't mean it's bad.
µsSLEEP gives you loop latency less than standard Sleep(1); i.e. in microseconds, not milliseconds.
The 5000000 in the examples above is just for an example, the real frequency in combat would be less than 1 ms

I don't understand your problem.
Do
you need it to be free of stress?
Put regular Sleep(20); in milliseconds.

There wasn't a complaint.
I don't need such a timer, I was studying it out of interest. But I find it a bad solution since it unnecessarily loads the processor.

And for what purpose do you need microsecond slip?

 
Andrey Khatimlianskii:

There was no complaint.
I don't need such a timer, studied it out of interest. But I find the solution bad, as it unnecessarily loads the processor.

What do you need a microsecond slip for?

If you wondered why it loads, and worked out why, you wouldn't have this opinion.
If you want less than 1ms, you'll have to pay for it with resource.
And it seems to me that you can't unload it, because you need microsecond timer to count interval.
On the other hand, if microsecond timer is constantly running and gives load equal to empty while,
then there is a question, why this delay then put, and use microsecond timer. Anyway, that's lyrical.
So, I'm pinging the server, with a certain frequency in while without delay.
And I need microsecond sampling, because there will be unnecessary calls.
I'm using first solution, which I posted earlier, and I wrote µsSleep as well, it may come in handy.


 
Andrey Khatimlianskii:


What purpose do you need a microsecond slip for?

Here is a ready-made solution.
Print() of course you replace it with your own code.

#define  SEND_PING                                           \
{                                                           \   
   ulong currCount = GetMicrosecondCount();                 \
   switch((currCount - prevCount) > 5000000)                \
   {                                                        \
      case 0:                                               \
         break;                                             \
      case 1:                                               \
         prevCount = currCount;                             \
         Print("ping");                                     \
         break;                                             \
   }                                                        \
}
       

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   ulong  prevCount = 0;
   
   while(!_StopFlag)
   {
      SEND_PING;
   }  
 
}
 
Renat Fatkhullin:
In the new tester we are writing, we will try to change this.
fxsaber:

Sent to the PM.

In the Tester, this EA generates millions of records of complete and reasonable (not spam) trade orders in the form of modifications. For this reason, the Tester's log catastrophically quickly gets clogged up.

These logs are not needed 99% of the time, but we often need what the Expert Advisor outputs via Print. Therefore, I would like to ask you again to consider the possibility of disabling automatic generation of entries for each OrderSend pack in the Tester.

If I understand correctly, disabling the generation of such strings will result in increased performance of single runs. I.e. the benefit is twofold.

 
Renat Fatkhullin:


But AMPGlobalEU-Live (actually it is better to search for it as AMPGlobalUSA-Live) for MetaTrader 5 with a physical platform core in Chicago is actually 19.53 ms, as our nearest servers are in New York:

Specially scanned all their points manually - the minimum is 19 ms.

We will try to put servers in Chicago in the next few days. Haven't gotten around to it.

The server in Chicago has been deployed.

Within 24 hours, it will scan all the servers and start distributing them.

Reason: