Ai maladitsa, you pissed yourself, you corrected yourself, another plug while we are not doing well.
A year ago I was suffering from this too, I had a lot of enthusiasm. Obstacles? No, I haven't seen any. Although maybe I'm just in a post-holiday mood ... :(
What is the cost of calling library functions compared to the cost of calling native class functions?
It's not just a simple wrapper, you have to call the library at every sneeze.
Good for you, you pissed yourself, you fixed yourself, another plug while we're not doing so well.
Actually, it's not so bad here.
It's a good article. I use libs all the time -- it's the only way of normal code separation so far.
You'd better tell me -- when will there be universal mega-neurons?
Urain:
What is the cost of calling library functions compared to the cost of calling native class functions?
I checked. There is no difference.
This call of the Test empty function when importing or including does not affect the time.
/* #import "Graph.ex5" void Test(long achart,string name,int awnd,int ax,int ay,colour aclr); #import */ #include "Graph.mq5" void OnStart() { long a=GetTickCount(); for (int i=0; i<1000000; i++) { Test(0, "qwe", 0, 10, 10, clrRed); } Print(string(GetTickCount()-a)); }
Actually, it's actually not that bad here.
The article is to the point. I use libs all the time -- it's the only way to separate code properly so far.
When will there be universal mega-neurons?
When will yours be?
Frankly speaking, I'll read your posts a bit more and give up MT5 altogether.
I'm sick of all these crutches to the core of my soul, wherever I turn everything is messed up, "and they are going to start the tram" :)
Neuronka is lying around somewhere, if you seriously with the mood to sit down there is a figment of work left, but no mood.
I checked. There is no difference.
such a call of the empty Test when importing or including does not affect the time.
As they say, feel the difference:
2012.01.06 16:46:28 Calculator(EURUSD,H1) empty=281
2012.01.06 16:46:28 Calculator (EURUSD,H1) lib=2344
//+------------------------------------------------------------------+ //|Test.mq5 | //+------------------------------------------------------------------+ #property library void Test(long achart,string name,int &awnd,int ax,int ay,color aclr) export { awnd=ax+ay; } //+------------------------------------------------------------------+
#import "Test.ex5" void Test(long achart,string name,int &awnd,int ax,int ay,color aclr); #import void OnStart() { int res=0; long a=GetTickCount(); for(int i=0; i<100000000; i++) { Test(0,"qwe",res,10,10,clrRed); } Print("liba=",string(GetTickCount()-a)); a=GetTickCount(); for(int i=0; i<100000000; i++) { res=10+10; } Print("empty=",string(GetTickCount()-a)); }
As they say, feel the difference:
No, you're asking about a function call, aren't you?
Or did you want to check the speed of loop execution?
I checked the difference between a simple function call or a call from ex5 bible. There is no difference in the speed of function calls.
It is clear that an empty loop without a function call will work faster. why check it at all.
No, you're asking about a function call, aren't you?
Or did you want to check the speed of the loop execution in general?
I checked the difference between a simple function call or a call from ex5 bible. There is no difference in the speed of function calls.
It is clear that an empty loop without a function call will work faster. why check it at all.
The loops are the same, the executed actions inside the loops are the same (in one case directly in the loop in the other case inside the function) the difference in time gives the net time of function call from the lib.
For the purity of the experiment, let's describe a similar function directly in the file:
2012.01.06 17:18:39 Calculator (EURUSD,H1) empty=281
2012.01.06 17:18:38 Calculator (EURUSD,H1) lib=2281
//+------------------------------------------------------------------+ //|Test.mq5 | //+------------------------------------------------------------------+ #property library void Test(long achart,string name,int &awnd,int ax,int ay,color aclr) export { awnd=ax+ay; } //+------------------------------------------------------------------+
#import "Test.ex5" void Test(long achart,string name,int &awnd,int ax,int ay,color aclr); #import void Testlocal(long achart,string name,int &awnd,int ax,int ay,color aclr) { awnd=ax+ay; } void OnStart() { int res=0; int count=100000000; long a=GetTickCount(); for(int i=0; i<count; i++) { Test(0,"qwe",res,10,10,clrRed); } Print("liba=",string(GetTickCount()-a)); a=GetTickCount(); for(int i=0; i<count; i++) { Testlocal(0,"qwe",res,10,10,clrRed); } Print("empty=",string(GetTickCount()-a)); }
To exclude the error, I even rewrote the loop length from one variable count, the result is the same.
I have 4.5 times
2012.01.06 17:28:33 test (EURUSD,D1) ex5=2047
2012.01.06 17:28:31 test (EURUSD,D1) local=438
Alex is this not enough for you?
4 times there, 2 times there, etc.
If we start writing bibles based on bibles, the brakes will grow like a snowball.
This scheme can be used provided that the bible itself does not use the bible call.
The difference in the speed of the above example is due to the fact that in one case the code optimiser completely overinlined such a simple function and completely excluded even the function call itself, while in the other case it was forced to call an external function honestly.
You should always take into account the inevitable influence of the code optimiser in tests. This loop example degenerates into res=100; in a decent compiler in the case of a local function.
Try to make the called function bigger to avoid inlining and test it again.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article Promote Your Development Projects Using EX5 Libraries is published:
Hiding of the implementation details of classes/functions in an .ex5 file will enable you to share your know-how algorithms with other developers, set up common projects and promote them in the Web. And while the MetaQuotes team spares no effort to bring about the possibility of direct inheritance of ex5 library classes, we are going to implement it right now.
Author: Alex Sergeev