MT4 runs EAs ridiculously slow. Someone knows why?

 

Here is the very simple code that I used to benchmark how fast is MT4 when working with EA functions:

int i=0;
int max=15000000;
int t0=0;

int init() {

   //-- test 1
   t0=GetTickCount();
   for (i=0; i<max; i++) {
      int a=1+2;
   }
   Print("test 1: "+(GetTickCount()-t0)+"ms");
   
   //-- test 2
   t0=GetTickCount();
   for (i=0; i<max; i++) {
      f();
   }
   Print("test 2: "+(GetTickCount()-t0)+"ms");
   
   return(0);
}
int start() {}

int f() {return(0);}

And here is the analog code for MT5:

int i=0;
int max=15000000;
uint t0=0;

int OnInit() {

   //-- test 1
   t0=GetTickCount();
   for (i=0; i<max; i++) {
      int a=1+2;
   }
   Print("test 1: "+(string)(GetTickCount()-t0)+"ms");
   
   //-- test 2
   t0=GetTickCount();
   for (i=0; i<max; i++) {
      f();
   }
   Print("test 2: "+(string)(GetTickCount()-t0)+"ms");
   
   return(0);
}

int f() {return(0);}


MT4 results:

test1: 156 ms

test2: 1279 ms


MT5 results:

test1: 46 ms

test2: 63 ms


It is even worse when in MT4 you have something inside the function, so this is really the best that I can get from a function call.

I tried this on many MT4 installations, on another fresh Windows with fresh MT4 and on older version of MT4 - there is no difference.

I will ask the support why is that, but if anyone knows something about this issue or how to fix it, I will be great.

 

Well, at least this problem is no more in the last MT4 build that is still hidden (not official). I just tried it and it works well, so I'm pretty happy that the well known MT4 is going to the garbage.

MetaQuotes, why not get rid of MT5 as well? Isn't it so obvious that it will never ever beat MT4, even when MT4 have some very annoying problems!

 

15 millions in 156 ms = 15.000 in 156 microsec = 15 in 156 nanosec

not so slow

and is well known MT5 is designed to run faster than MT4, 3 times in the 1st test and 20 the 2nd

3 and 20 dont look so big to me

 

I used 15 million cycles because I calculated that 1 year have about 15 million ticks. And these results are for a single empty function (the fastest function call), so yes, it does not look so slow from that point of view, but if you have many functions or the EA needs to be optimized those nanoseconds can easily turn into minutes, hours, days and months :) For no reason really :)

I always had this opinion that MT4 is very slow on backtesting and because of that making of EA is slow and tricky, but hopefully with the new builds it will be better.

 

wow a 2000% performance increase is huge

 
SDC: wow a 2000% performance increase is huge
I get 3700% difference for empty function calls on my machine. Yeah, its no contest... the implications is worse then most people would think. I just realize recently that this could mean a difference between Minutes vs Days during optimization. I'm one of those people who do-not care about speed, been a while since I've used any strategy-optimizer, and I generally think that if my start() completes faster then the average tick-speed ... I-don't-care. And even I think thats bad.
 

Yes that is going to make a huge difference for optimization times, I had not realized this difference in performance between mt4 and mt5. I skimmed through that other thread where you and 2cent were comparing overloaded functions vs a regular function with a switch, it looks like you are way ahead of me in coding with the new mql4 I got some catching up to do lol

Reason: