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
 

 

which is fast either ADD or COMPUTE

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

New User


Joined: 15 Sep 2005
Posts: 2
Location: pune

PostPosted: Thu Sep 15, 2005 7:40 pm    Post subject: which is fast either ADD or COMPUTE
Reply with quote

I want to know , in arthemetic calculations which one is faster

Either ADD or COMPUTE?
Which one is preferble ? when ?

please rectify my doubt.
Back to top
View user's profile Send private message

michaelraj

New User


Joined: 01 Sep 2005
Posts: 43
Location: Bangalore

PostPosted: Fri Sep 16, 2005 1:00 pm    Post subject:
Reply with quote

Hi Suresh,

I can not exactly say which one is faster. But I can say to prefer COMPUTE. As in COMPUTE we can control through ON SIZE phrase, if the destination field is overflowed by any chance. I think it is not possible by ADD.

Regards,
Mike.
Back to top
View user's profile Send private message
prasanth_thavva

New User


Joined: 28 Jul 2005
Posts: 86
Location: Chennai

PostPosted: Fri Sep 16, 2005 3:14 pm    Post subject: regarding Add and Compute
Reply with quote

hi
Quote:
Add is faster than compute


if any wrong plz correct me
bye all d best
Back to top
View user's profile Send private message
amalli

New User


Joined: 06 Sep 2005
Posts: 17

PostPosted: Fri Sep 16, 2005 3:38 pm    Post subject: regarding Add and Compute
Reply with quote

hi prasanth

why add is faster then compute? give resons...........


thnaks
malli
Back to top
View user's profile Send private message
suresh Reddy allampati

New User


Joined: 15 Sep 2005
Posts: 2
Location: pune

PostPosted: Tue Sep 20, 2005 7:10 pm    Post subject: Re: regarding Add and Compute
Reply with quote

Hi prasanth,
Thank u . But how it is fast, it is one of the interw question.
plz tell me the cause

suresh

prasanth_thavva wrote:
hi
Quote:
Add is faster than compute


if any wrong plz correct me
bye all d best
Back to top
View user's profile Send private message
Sridevi_C

Active User


Joined: 22 Sep 2005
Posts: 104
Location: Concord, New Hampshire, USA.

PostPosted: Wed Sep 28, 2005 10:49 pm    Post subject:
Reply with quote

michaelraj wrote:
Hi Suresh,

I can not exactly say which one is faster. But I can say to prefer COMPUTE. As in COMPUTE we can control through ON SIZE phrase, if the destination field is overflowed by any chance. I think it is not possible by ADD.

Regards,
Mike.



Hi,
ON SIZE phrase can be used with any arithmetic verb like ADD,SUBTRACT,MULTIPLY & DIVIDE,in the same way as it is used in COMPUTE.
ADD should be faster.Because it always refers to addition operation and so internal implementation would direct for addition immediately and move the result to destination.
In case of COMPUTE, any operation-add,subtract,multiply,divide and/or exponent can be done.So internally it would take some time to check for the type of operation to be performed and then addition operation would be selected and finally the result is moved to destination.So COMPUTE must be slow when compared to ADD.
Do correct me for any mistake(s).
Thanks!
Sridevi.
Back to top
View user's profile Send private message
Hames

New User


Joined: 03 Oct 2005
Posts: 49

PostPosted: Tue Oct 04, 2005 3:38 pm    Post subject:
Reply with quote

Hi,

Sridevi's point is correct!

ADD is only a single operation Where as COMPUTE will normally contain more than one operation. So logically COMPUTE will take more time.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Oct 06, 2005 12:40 am    Post subject:
Reply with quote

The best way to determine which is "faster" is to put add and compute in a pgm and compile it w/the "list,nooff" options. Then check the Assembler code generated by each. The one w/the least code generated will be the faster of the 2.

BTW, the checking mentioned in earlier posts will be done at compile time, when the Assembler code is generated, not at execution, so no exec time will be spent on checking.
Back to top
View user's profile Send private message
Sridevi_C

Active User


Joined: 22 Sep 2005
Posts: 104
Location: Concord, New Hampshire, USA.

PostPosted: Thu Oct 06, 2005 12:55 am    Post subject:
Reply with quote

Hi Jack,
Thanks for your valuable info.
Sridevi.
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 ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts FAST UNLOAD and LOAD issue GaganGarg DB2 1 Mon Feb 15, 2016 2:30 pm
No new posts which execution will be fast Catherine Wesley Mainframe Interview Questions 11 Mon Jan 26, 2015 2:27 pm
No new posts Compute statement not working sandeep kumar302 COBOL Programming 5 Wed Apr 02, 2014 7:12 pm
No new posts Getting S0C7 in the compute statement raviprabhu COBOL Programming 4 Mon Feb 17, 2014 10:23 pm


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