Which is the fastest statement to run...

techniquetechnique Member Posts: 21
We all write code like this all the time so I'm looking for THE definitive answer in terms of performance.

In NAV2017+ which is the fastest statement:

1)
IF GLSetup.GET THEN
IF GLSetup.Fieldname THEN
DoSomething := TRUE;

or

2)
IF (GLSetup.GET) AND (GLSetup.Fieldname) THEN
DoSomething := TRUE;

The 2nd one is my preference and I think it is neater but want the one that executes fastest...

Best Answer

Answers

  • AKAK Member Posts: 226
    edited 2018-01-30
    No guesswork needed. Set both of the code snippets into a loop and count the time for x loops. I would bet the difference is negligible in any scenario since there is no real difference in what is done nor in what order it is done. It might very well be that the compiler produces the same code for both examples.
    I would care for that if we would code in assembler and counting CPU cycles, but we have to worry more about what is going on on the SQL server side.
Sign In or Register to comment.