Performance impact using Begin/End statement

navninja
Member Posts: 2
Hi,
I was wondering if there is any performance impact when using Begin/End. I have 2 different examples and was wondering if they are really only style differences or if there is an underlying performance hit when using Begin/End when it is not really needed.
Example 1:
IF <condition> THEN
<Do Something>;
vs
IF <condition> THEN BEGIN
<Do Something>;
END;
Example 2
IF Record.FINDSET THEN
REPEAT
<Do Something>;
UNTIL Record.NEXT = 0;
vs
IF Record.FINDSET THEN BEGIN
REPEAT
<Do Something>;
UNTIL Record.NEXT = 0;
END;
Thank you in advance.
I was wondering if there is any performance impact when using Begin/End. I have 2 different examples and was wondering if they are really only style differences or if there is an underlying performance hit when using Begin/End when it is not really needed.
Example 1:
IF <condition> THEN
<Do Something>;
vs
IF <condition> THEN BEGIN
<Do Something>;
END;
Example 2
IF Record.FINDSET THEN
REPEAT
<Do Something>;
UNTIL Record.NEXT = 0;
vs
IF Record.FINDSET THEN BEGIN
REPEAT
<Do Something>;
UNTIL Record.NEXT = 0;
END;
Thank you in advance.
0
Answers
-
I suspect not. I suspect that code will be optimised before execution0
-
I always use begin end structures. Much easier to read, upgrade and copy into other code snippets.
Can't think of any reason then (lazy) to not use it.0 -
Lets suppose there is a performance impact in executing the code. We would be talking about microseconds.
If you do some database access, we are talking about milliseconds.
So 1 millisecond (generally more) for a database access + 10 microseconds (I think I am thinking LARGE!) for the extra processing = 1010 microseconds for everything.
=> I wouldn't care about those 10 microseconds!Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
The instructions generated by the compiler are exactly the same independent of BEGIN / END being used or not. Which also means that there is no speed penalty when the code is executed.
And as Kriki points out database access is where most of the time is spend which makes it a lot more important to write code that is readable than code which executes a couple of milliseconds fasterThis posting is provided "AS IS" with no warranties, and confers no rights.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions