Is <11 faster than <=10?

 

<11 faster than <=10?

for example

if(b>0 && b<11)

vs 

if(b>0 && b<=10)


Is the first one faster bc its just one thing < vs <=? Worth it?

 
Exactly the same (for integers.)
 
William Roeder:
Exactly the same (for integers.)
A little weird that 2 things same as 1
 
theoretically, yes it is faster, but it still depends on the mql compiler if it checks first the "<" and execute right away when true. speed is basically in milliseconds so you will not feel the difference in regular script but if you run script with exhausting  loop and the condition is in the middle of the loop, the first method will help.
 
Joel Protusada:
theoretically, yes it is faster, but it still depends on the mql compiler if it checks first the "<" and execute right away when true. speed is basically in milliseconds so you will not feel the difference in regular script but if you run script with exhausting  loop and the condition is in the middle of the loop, the first method will help.

Can you justify your theory with a source ? I don't think so.

We are not talking here about milliseconds, but about nanoseconds.

There is no difference in execution speed between these 2 options.

 
nadiawicket:
A little weird that 2 things same as 1

Assembler wise it's exactly the same thing.
one machine instruction for greater and one machine instruction for greater equal. same thing.
Assembly conditions

Assembly - Conditions - Tutorialspoint
Assembly - Conditions - Tutorialspoint
  • www.tutorialspoint.com
Assembly - Conditions - Conditional execution in assembly language is accomplished by several looping and branching instructions. These instructions can change the flow of control in a
 
Alain Verleyen:

Can you justify your theory with a source ? I don't think so.

We are not talking here about milliseconds, but about nanoseconds.

There is no difference in execution speed between these 2 options.

I respect your belief but it is actually different. The layman's explanation is this...

"b<11" is like asking one question.

"b<=10" is like asking two questions. The first question is "Is b less than 10?" if true it will execute the script for "true". If it's false, it raise the next question "Is b equal to 10?". Theoretically each question consume milliseconds of execution. If the first question is false then it consumes more time as it will ask the next question.

That is in theory on designing a compiler. I don't know how MQL compiler did it so I don't really know if this theory is applicable with it.

I used to be a compiler designer and assembly language programmer for more than 10 years that's why I know. I just got tired of it so I quit and looked for something more exciting.

 
Joel Protusada:

I respect your belief but it is actually different. The layman's explanation is this...

"b<11" is like asking one question.

"b<=10" is like asking two questions. The first question is "Is b less than 10?" if true it will execute the script for "true". If it's false, it raise the next question "Is b equal to 10?". Theoretically each question consume milliseconds of execution. If the first question is false then it consumes more time as it will ask the next question.

That is in theory on designing a compiler. I don't know how MQL compiler did it so I don't really know if this theory is applicable with it.

I used to be a compiler designer and assembly language programmer for more than 10 years that's why I know. I just got tired of it so I quit and looked for something more exciting.

You must be kidding. "b<=10" is absolutely not "two questions", as explained in the links posted by Amir and me, there is an instruction at CPU level for both. If the compiler translate "b<=10" in 2 instructions it's just a bad compiler.
 
Alain Verleyen:
You must be kidding. "b<=10" is absolutely not "two questions", as explained in the links posted by Amir and me, there is an instruction at CPU level for both. If the compiler translate "b<=10" in 2 instructions it's just a bad compiler.

Are you sure MQL uses that instructions? It's all in theory as I have said. No one among us knows what's inside the compiler. Your theory is as good as mine.

 

It says...

"Conditional execution in assembly language is accomplished by several looping and branching instructions. These instructions can change the flow of control in a program. Conditional execution is observed in two scenarios"

Each loop execute in milliseconds. I hope you get the idea.

 
Also the transalation of "b<=10" is not translated directly to any of the jump instructions.  It doesn't understand that. You'v egot to make a a lot of script just to get each character and create a lot of loops to convert it to the right translation before it execute the 2 questions. It's not like what human does.
Reason: