Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Subroutines vs PERFORM in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Sasi Kiran Patha
Warnings : 2

New User


Joined: 19 Nov 2006
Posts: 73
Location: Hyederabad

PostPosted: Wed Mar 14, 2007 9:21 am    Post subject: Subroutines vs PERFORM in COBOL
Reply with quote

Hi,

In our shop we came to know of a finding relating to
Subroutines vs PERFORM.

Suppose a PARA (module) is performed using PERFORM 9999 times.
If we code the Para as a subroutine module and call the subroutine 9999 times does the time complexity increase and hence the performance decrease.

There are 2 cases here again, we have to evaluate the time complexity
if the subroutine has Db2 cursors and the other case where the subroutine has no Db2 calls or has a mixture of Db2 cursors and
normal loop structured processing.

Is it more manageble using the perform module or a subroutine module
in case the subroutine is called from one program.

Regards,
Sasi Patha.
Back to top
View user's profile Send private message

agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Wed Mar 14, 2007 2:51 pm    Post subject:
Reply with quote

I think you forgot to put question mark/s. icon_biggrin.gif (Please do that so that we can know exact question )
About management, I feel it is easier to mange it if it is in a para (using Perform)
Because,
1. routine is getting used in a single program
2. recompilation and stuff.

Hope to here from you soon. icon_smile.gif
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: Wed Mar 14, 2007 7:51 pm    Post subject:
Reply with quote

Hello,

One way to determine if you would use a PERFORM or a CALL if if multiple programs need the same process.

If several programs need the same logis, the CALL is usually preferable. If the routine is only needed in one program, the PERFORM is usually preferable.
Back to top
View user's profile Send private message
Sasi Kiran Patha
Warnings : 2

New User


Joined: 19 Nov 2006
Posts: 73
Location: Hyederabad

PostPosted: Wed Mar 14, 2007 8:00 pm    Post subject: Re: Subroutines vs PERFORM in COBOL
Reply with quote

Hi,

What about the performance?
If the subprogram has Db2 cursors and the subprogram will be called 9999 times say.
If the same Db2 cursors are processed in a Perform module which will be performed 9999 times.

Are the execution times and performance benefits same in both the cases?

Regards,
Sasi Patha.
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: Wed Mar 14, 2007 8:32 pm    Post subject:
Reply with quote

Hello,

Please realize that for the most part, a CALL and a PERFORM both cause a transfer of control to another part of the executable and then return to the next statement. I the CALL is dynamic, the called module must be loaded into memory as part of the first call, but when you are going to issue the CALL 10k times, that will not be even measurable.

If you are concerned about performance, the interaction with DB2 will have much more impact than the CALL/PERFORM.

As i mentioned earlier, CALL versus PERFORM is often (usually) determined by how many programs need the "common" code. If one - PERFORM, if multiple - CALL. There can be exceptions, but they should be looked at individually.
Back to top
View user's profile Send private message
Sasi Kiran Patha
Warnings : 2

New User


Joined: 19 Nov 2006
Posts: 73
Location: Hyederabad

PostPosted: Thu Mar 15, 2007 9:27 am    Post subject: Re: Subroutines vs PERFORM in COBOL
Reply with quote

hi,

PERFORM and CALL transfer control. I agree. Call should transfer control
to another adress space, adress space of the called program which should consume more resources.

Correct me if im worng.

Regards,
Sasi Patha.
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 15, 2007 7:00 pm    Post subject:
Reply with quote

Hello,

CALL doesn't use "another" address space. The called module is loaded into the same address space ot the caller.

When you use a static call, the called code physically becomes part of the calling load module. If the call is dynamic, the called module must be fetched from the library at runtime, but as i mentioned earlier, if there are 10k calls, the one-time load will not even be noticeable.

Either way, if the called module is 100k, 100k will be needed for the called code.
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 149
Location: Ottawa Canada

PostPosted: Mon Mar 26, 2007 8:51 pm    Post subject:
Reply with quote

PERFORM will run faster than a dynamic CALL but the difference will not be significant 99% of the time. As Dick mentioned, your DB2 activity is by far the most important factor in determining performance. If your program is designed intelligently and you do your DB2 correctly, then you don't have to worry about anything else.

My group does a lot of performance work. We almost never worry about whether a piece of logic was performed versus called. There are some exceptions. If you are interested - just ask - and I will list them.

The decision to use PERFORM versus CALL will almost always depend on other factors. Packaging issues - maintenance issues. For example, if the code is shared by other routines then you want it in its own subroutine.
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
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us