Is <11 faster than <=10? - page 3

 
Amir Yacoby:

You seem to confuse execution with  parsing. Parsing is done before execution in compilers, it won't affect the execution time which starts only after all parsing is finished and the assembly program is ready and only then it is run. As also confirmed by Ilyas 2 posts above, this is the answer. 

Saying the same, I missed your post.
 
Alain Verleyen:

And you insist, really ?

All you reasoning above is completely irrelevant. The topic is not about how fast it is to compile a source code but how fast it is to execute a compiled code. Without starting a detailed discussion about how a compiler (actually a lexer/parser) works, if your compiler can't translate ">=" into 1 assembly instruction (JLE) but translate it into 2 instructions (JL + JZ/JNZ), you have a serious problem and your compiler will be very bad.

You are quite stubborn, isn't the answer from Ilyas, a Metaquotes developper enough to convince you ? It seems really hard for you to admit you are wrong, but you are without a question.

Hey, from the start I stated that I respect your opinion. I'm just expressing my own opinion and you are also free to express yours. This is a forum. That's how it should work. It's a two way street.  I'm discussing. I'm not the one insisting.

 
Joel Protusada:

Hey, from the start I stated that I respect your opinion. I'm just expressing my own opinion and you are also free to express yours. This is a forum. That's how it should work. It's a two way street.  I'm discussing. I'm not the one insisting.

You missed the point totally, I didn't express any opinion. This is not about opinions, this is about facts and scientific attitude. We are here on a mql4 coding forum, not a chit-chat forum.
 
Ilyas:

Exactly the same in MQL4 and MQL5


Exactly the same/very negligible for all Data Types in MQL4 and also the exact same situation when handling all Data Types in MQL5?

This is due to the fact that at some point in the compiling/parsing the instructions we type in MetaEditor (for ALL Data Types) get translated/processed in a such a manner that its essentially the same microseconds consumed from one step to next regardless of it being 1 (as in just <) or 2 (as in  <=) "comparisons"?

Great to know we don't need to change every <= into < in order to have more efficient code.
 
Seng Joo Thio:

I did this simple test:

And I gathered these results:

Test Run 1 Run 2 Run 3 Run 4 Run 5
< 5573237 5538121 5640963 5604254 5566550
<= 5618423 5582935 5671609 5623322 5600941

Clearly, < is faster than <=, although the difference is negligible.

Amir Yacoby:

It clearly does not say what you claim (average difference is 0.62 percent).

My tests show the opposite:

Seems to me this discrepancy is due to different approaches to testing

 
nadiawicket:

Seems to me this discrepancy is due to different approaches to testing

To some extent, you're right - for one, I noticed (subsequently) that swapping the sequence of the two tests can give rise to different bias. Also, fluctuation in pc load affects the results too. 

However, the actual performances have to be quite close, if not equal, because otherwise the results should always lean towards one side (with differing magnitude of differences).

 
nadiawicket:

Great to know we don't need to change every <= into < in order to have more efficient code.

Try to run this code in the MT5 (64 bit version)

2019.09.12 10:21:45.653 SpeedTest (EURUSD,H1)   Microseconds elapsed (<) = 0
2019.09.12 10:21:45.653 SpeedTest (EURUSD,H1)   Microseconds elapsed (<=) = 0
 

On MT4, I have confirmed by running these 2 different EAs 10 times each on the Strategy Tester.

Indeed, the elapsed time seems to persistently be the exact same phenomena; either 0 or 1 microsecond for the 2 EA's the same.

This clearly proves that its essentially the same time for the 2 computations at least at the microsecond level in basic usage according to the Terminal.

//+------------------------------------------------------------------+
//|                                                    SpeedTest.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Print(GetMicrosecondCount(),10<11,GetMicrosecondCount());
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  }
//+------------------------------------------------------------------+


Second test

//+------------------------------------------------------------------+
//|                                                    SpeedTest2.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Print(GetMicrosecondCount(),10<=11,GetMicrosecondCount());
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  }
//+------------------------------------------------------------------+
 
nadiawicket:

On MT4, I have confirmed by running these 2 different EAs 10 times each on the Strategy Tester.

Indeed, the elapsed time seems to persistently be the exact same phenomena; either 0 or 1 microsecond for the 2 EA's the same.

This clearly proves that its essentially the same time for the 2 computations at least at the microsecond level according to the Terminal.


Second test

What do you know about constant expressions?

Of course both of them was caclulated on compile time

You can change you code to below code, it will spend the same time

Print(GetMicrosecondCount(),true,GetMicrosecondCount());
 
That's how I know I'm not a geek :-) 
Reason: