IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

which is fast either ADD or COMPUTE


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts A way to see a particular file fast w... TSO/ISPF 10
No new posts Compute statement with Cobol Z/os 5.2 COBOL Programming 2
No new posts ROUNDED Problem with COMPUTE statement COBOL Programming 11
No new posts FAST UNLOAD and LOAD issue DB2 1
No new posts which execution will be fast Mainframe Interview Questions 11
Search our Forums:

Back to Top