Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Better performance switch OR group var in IF

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sutirtha mukherjee

New User


Joined: 04 Mar 2008
Posts: 6
Location: Chennai

PostPosted: Tue Mar 11, 2008 7:40 pm    Post subject: Better performance switch OR group var in IF
Reply with quote

Hi,

Can anyone help me out of this..
I ran a strobe request and it is pointing to a section of code where
i have used a IF statement with 2 else and a lot of OR and AND conditinos
i.e.
if var1 = 1 or 3 and var2 = 3 or 6
else if condition with many or/and

My question is if use a switch instead or the var1 or variable will i get a performance boost?
Back to top
View user's profile Send private message

rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 95
Location: India

PostPosted: Tue Mar 11, 2008 7:57 pm    Post subject: Reply to: which would give better performance-switchORgroup
Reply with quote

Hi Sutirtha,
It is advisable that you use switch statement instead of nested if. Since, some compilers will not support more than 4 or 5 nested level. Also, the code looks simple and understandable easily while using switch statement.
In the switch you can use and/ or as your requirement.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Mar 11, 2008 8:38 pm    Post subject:
Reply with quote

I have been around IT for a day or two, but this one has me. What language has a SWITCH command? what is a SWITCH command?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10231
Location: italy

PostPosted: Tue Mar 11, 2008 8:44 pm    Post subject: Reply to: which would give better performance-switchORgroup
Reply with quote

switch is a C ( maybe JAVA ) construct
Code:
switch (variable) {
    case expression1:
        ..... ;
    break;
    case expression2:
        ..... ;
    break;
    case expression3:
        ..... ;
    break;
    default:
        ...... ;   
}
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 11, 2008 9:05 pm    Post subject: which would give better
Reply with quote

How about a COBOL EVALUATE?

It's easy to maintain and even easier to comprehend.

Many times, maintenance causes well-intentioned "IF-THEN-ELSE" constructs to wind up looking looking like a Chinese menu (no offence implied), causing programmers to apply some "creative" code.

As most of us have been around the block a few times, I myself have had to resort to generating the ASSEMBLER expansion of a COBOL program, because the logic has become so convoluted, it's the only way it can be followed.

When you have an "IF" ending in 6 right-parenthesis, embedded with OR's and AND's, as well as other nested "IF"'s and "ELSE"s, it's time for review and apply a different approach.

Just my .02 cents....

Regards,

Bill
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Mar 11, 2008 9:22 pm    Post subject:
Reply with quote

As far as I know MAINFRAME cobol doesn't have a switch!
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Mar 11, 2008 10:29 pm    Post subject:
Reply with quote

Hi,

EVALUATE should work for Your scenario..try the below feacture of EVALUATE
Code:
EVALUATE TRUE ALSO TRUE


Check the manuals please, it should be doable.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Mar 11, 2008 10:29 pm    Post subject:
Reply with quote

Hello,

On many of the systems i've supported the "switch" is just a field that can be turned "on" or "off" and then tested in the code. Many have 88 levels to use a name rather than a value (i.e. "if switch-on. . ." rather than "if swiotch-field = 1).
Back to top
View user's profile Send private message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 95
Location: India

PostPosted: Wed Mar 12, 2008 2:48 pm    Post subject: Reply to: which would give better performance-switchORgroup
Reply with quote

Hi All,
Sorry for the confusion... I knew in cobol there is no switch statement like c/c++/java.... In my reply I mentioned Evaluate statement as switch. Since, he had mentioned as switch and I simply followed it icon_sad.gif .
Back to top
View user's profile Send private message
sutirtha mukherjee

New User


Joined: 04 Mar 2008
Posts: 6
Location: Chennai

PostPosted: Wed Mar 12, 2008 5:39 pm    Post subject: which would give better performance-switchORgroup var in IF
Reply with quote

sorry all ,
i created the confusion ...

actually i intended to ask this:

var pic s9(4) comp. (mine is a comp variable)

"if var = 2
imperative statement"
would perform better

OR

var value 1
88 var-flag pic x value 1
"if var-flag
imperative statement"

would perform better ?


(NOTE:i am using only the variable for comparision only no arithmetic operations)
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 788
Location: Chennai, India

PostPosted: Wed Mar 12, 2008 5:49 pm    Post subject:
Reply with quote

I prefer second one.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Wed Mar 12, 2008 5:59 pm    Post subject:
Reply with quote

Bill -

Your opinions are worth much more than 2/100 of a cent to me.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Mar 13, 2008 12:27 am    Post subject:
Reply with quote

Hello,

Quote:
would perform better ?
It would be difficult to measure the difference as they are both "the same".

If you look at the generated assembler, you will be able to see the actual code.

Quote:
Your opinions are worth much more than 2/100 of a cent to me
Me too - at least 19/100 of a cent. . . icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Why TS/OP would Not contact site supp... RahulG31 All Other Mainframe Topics 2 Wed Mar 22, 2017 7:46 am
No new posts Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts BC, BCR, BRC, BRCL performance steve-myers PL/I & Assembler 0 Fri Dec 23, 2016 7:44 am
No new posts PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 4 Mon Dec 05, 2016 11:57 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us