View previous topic :: View next topic
|
Author |
Message |
prash_infy
New User
Joined: 31 Aug 2006 Posts: 20
|
|
|
|
Want to know which is more efficient in performance and why.
Code: |
IF WS-VAR1 = 'A'
GOTO PROCESS
END-IF
*
IF WS-VAR2 > 0
GOTO PROCESS
END-IF |
OR
Code: |
IF WS-VAR1 = 'A' OR WS-VAR2 > 0
GOTO PROCESS
END-IF |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
One way to be more efficient is to make sure that the condition most likely to be true is specified first. . .
You could also run some timing tests but you would need to have a few million records . . . |
|
Back to top |
|
|
prash_infy
New User
Joined: 31 Aug 2006 Posts: 20
|
|
|
|
Thanks d.sch
Of the two codes mentioned above, which one do you think is more efficient? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
As i mentioned, the one that looks at the value most likely to be true first will be more efficient.
Either format will probably run about the same, so you want to eliminate as many "false" tests as possible to reduce the amount of internal processing.
The only way you can see this is to run some very large tests. A small test will show very little or no difference. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
prash_infy,
what Dick is trying to get you to do is
consider the impact of
IF WS-VAR2 > 0 or WS-VAR1 = 'A'
versus
IF WS-VAR1 = 'A' or WS-VAR2 > 0
are there more WS-VAR2 situations
than WS-VAR1?
the first condition, if true, will cause immediate transfer
otherwise
the second condition is checked.
So if you need to determine if there is statistically
(based on analysis of input data)
a higher chance of one over the other occuring;
the statistically higher should be coded first.
This is also referred to as fast track. |
|
Back to top |
|
|
prash_infy
New User
Joined: 31 Aug 2006 Posts: 20
|
|
|
|
Thanks Mr Brenholtz!!!! |
|
Back to top |
|
|
|