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

Which one is fater, COMP or COMP3 and why


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mf_kumar

New User


Joined: 10 Jan 2006
Posts: 1

PostPosted: Fri Apr 28, 2006 11:59 am
Reply with quote

Hi ,
Please any one give the answer this question.

Which one is fater, COMP or COMP3 and why ?

regards,
kumar.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Apr 29, 2006 4:29 am
Reply with quote

Generally, if COMP is kept under 8 bytes it's faster than COMP-3. Why? Because COMP uses register to register (RR) Assembler instructions; COMP-3 uses storeage to storage (SS).

That's basically one reason why an INDEX is preferable to a SUBSCRIPT and COMP is recommended for SSs.

There are exceptions involving the number of calcs and the size of tables having to do with overhead is not "recovered" when small execution volumes are processed.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Mon May 01, 2006 10:29 pm
Reply with quote

Hello kumar,

Jack is absolutely correct, individual instructions using COMP values are faster than instructions using COMP-3 values.

But, I?m going to throw a wrench into the works. Even through COMP instructions are faster, you sometimes use more of them to perform the same task.

Here are a few examples of the COBOL code and the generated Assembler code, and as you can see, it makes a big difference in the mix of COMP COMP-3 and the calculations you do.

Code:


 01 WS-COMP                PIC S9(9)  COMP  VALUE 1000.   
 01 WS-COMP-3              PIC S9(9)  COMP-3 VALUE 1000. 
 01 WS-RESULT-COMP         PIC S9(9)  COMP.               
 01 WS-RESULT-COMP-3       PIC S9(9)  COMP-3.             


.000021  COMPUTE WS-RESULT-COMP = WS-COMP + WS-COMP.
                                                               
.   000240  5820 8000               L     2,0(0,8)                WS-COMP       
.   000244  8E20 0020               SRDA  2,32(0)                               
.   000248  5840 8000               L     4,0(0,8)                WS-COMP       
.   00024C  8E40 0020               SRDA  4,32(0)                               
.   000250  1A42                    AR    4,2                                   
.   000252  1E53                    ALR   5,3                                   
.   000254  47C0 B044               BC    12,68(0,11)             GN=11(00025C)
.   000258  5A40 C004               A     4,4(0,12)               SYSLIT AT +4 
.   00025C                 GN=11    EQU   *                                     
.   00025C  5050 8010               ST    5,16(0,8)               WS-RESULT-COMP

.000023  COMPUTE WS-RESULT-COMP-3 = WS-COMP-3 + WS-COMP-3.
                                                                 
.   000260  D204 8018 8008          MVC   24(5,8),8(8)            WS-RESULT-COMP-3
.   000266  FA44 8018 8008          AP    24(5,8),8(5,8)          WS-RESULT-COMP-3
.   00026C  F844 8018 8018          ZAP   24(5,8),24(5,8)         WS-RESULT-COMP-3

.000025  COMPUTE WS-RESULT-COMP-3 = WS-COMP + WS-COMP.
                                                                 
.   000272  5820 8000               L     2,0(0,8)                WS-COMP       
.   000276  8E20 0020               SRDA  2,32(0)                               
.   00027A  5840 8000               L     4,0(0,8)                WS-COMP       
.   00027E  8E40 0020               SRDA  4,32(0)                               
.   000282  1A42                    AR    4,2                                   
.   000284  1E53                    ALR   5,3                                   
.   000286  47C0 B076               BC    12,118(0,11)            GN=12(00028E)
.   00028A  5A40 C004               A     4,4(0,12)               SYSLIT AT +4 
.   00028E                 GN=12    EQU   *                                     
.   00028E  5D40 C000               D     4,0(0,12)               SYSLIT AT +0 
.   000292  4E50 D100               CVD   5,256(0,13)             TS2=16       
.   000296  F154 D0F0 D103          MVO   240(6,13),259(5,13)     TS2=0         
.   00029C  4E40 D100               CVD   4,256(0,13)             TS2=16       
.   0002A0  9110 D0F5               TM    245(13),X'10'           TS2=5         
.   0002A4  D204 D0F5 D103          MVC   245(5,13),259(13)       TS2=5         
.   0002AA  4780 B09A               BC    8,154(0,11)             GN=13(0002B2)
.   0002AE  9601 D0F9               OI    249(13),X'01'           TS2=9         
.   0002B2                 GN=13    EQU   *                                     
.   0002B2  F844 8018 D0F5          ZAP   24(5,8),245(5,13)       WS-RESULT-COMP-3

.000027  COMPUTE WS-RESULT-COMP-3 = WS-COMP + WS-COMP-3.
                                                               
.   0002B8  5820 8000               L     2,0(0,8)                WS-COMP       
.   0002BC  8E20 0020               SRDA  2,32(0)                               
.   0002C0  5D20 C000               D     2,0(0,12)               SYSLIT AT +0 
.   0002C4  4E30 D100               CVD   3,256(0,13)             TS2=16       
.   0002C8  F154 D0F0 D103          MVO   240(6,13),259(5,13)     TS2=0         
.   0002CE  4E20 D100               CVD   2,256(0,13)             TS2=16       
.   0002D2  9110 D0F5               TM    245(13),X'10'           TS2=5         
.   0002D6  D204 D0F5 D103          MVC   245(5,13),259(13)       TS2=5         
.   0002DC  4780 B0CC               BC    8,204(0,11)             GN=14(0002E4)
.   0002E0  9601 D0F9               OI    249(13),X'01'           TS2=9         
.   0002E4                 GN=14    EQU   *                                     
.   0002E4  FA54 D0F4 8008          AP    244(6,13),8(5,8)        TS2=4         
.   0002EA  F844 8018 D0F5          ZAP   24(5,8),245(5,13)       WS-RESULT-COMP-3

.000029  COMPUTE WS-RESULT-COMP   = WS-COMP + WS-COMP-3. 
                                                               
.   0002F0  5820 8000               L     2,0(0,8)                WS-COMP       
.   0002F4  8E20 0020               SRDA  2,32(0)                               
.   0002F8  F874 D0F0 8008          ZAP   240(8,13),8(5,8)        TS2=0         
.   0002FE  4F40 D0F0               CVB   4,240(0,13)             TS2=0         
.   000302  8E40 0020               SRDA  4,32(0)                               
.   000306  1A24                    AR    2,4                                   
.   000308  1E35                    ALR   3,5                                   
.   00030A  47C0 B0FA               BC    12,250(0,11)            GN=15(000312)
.   00030E  5A20 C004               A     2,4(0,12)               SYSLIT AT +4 
.   000312                 GN=15    EQU   *                                     
.   000312  5030 8010               ST    3,16(0,8)               WS-RESULT-COMP

.000031  COMPUTE WS-RESULT-COMP   = WS-COMP-3 + WS-COMP-3.
                                                               
.   000316  F874 D0F0 8008          ZAP   240(8,13),8(5,8)        TS2=0         
.   00031C  FA54 D0F2 8008          AP    242(6,13),8(5,8)        TS2=2         
.   000322  F895 D100 D0F2          ZAP   256(10,13),242(6,13)    TS2=16       
.   000328  D202 D0F8 C008          MVC   248(3,13),8(12)         TS2=8         
.   00032E  D204 D0FB D105          MVC   251(5,13),261(13)       TS2=11       
.   000334  4F20 D0F8               CVB   2,248(0,13)             TS2=8         
.   000338  F144 D0FB D100          MVO   251(5,13),256(5,13)     TS2=11       
.   00033E  4F50 D0F8               CVB   5,248(0,13)             TS2=8         
.   000342  5C40 C000               M     4,0(0,12)               SYSLIT AT +0 
.   000346  1E52                    ALR   5,2                                   
.   000348  47C0 B138               BC    12,312(0,11)            GN=16(000350)
.   00034C  5A40 C004               A     4,4(0,12)               SYSLIT AT +4 
.   000350                 GN=16    EQU   *                                     
.   000350  1222                    LTR   2,2                                   
.   000352  47B0 B142               BC    11,322(0,11)            GN=17(00035A)
.   000356  5B40 C004               S     4,4(0,12)               SYSLIT AT +4 
.   00035A                 GN=17    EQU   *                                     
.   00035A  5050 8010               ST    5,16(0,8)               WS-RESULT-COMP

.000033  ADD 1 TO WS-COMP-3.
                                                                   
.   00035E  FA40 8008 A01B          AP    8(5,8),27(1,10)         WS-COMP-3     
.   000364  F844 8008 8008          ZAP   8(5,8),8(5,8)           WS-COMP-3
     
.000035  ADD 1 TO WS-COMP.
                                                                     
.   00036A  5820 8000               L     2,0(0,8)                WS-COMP       
.   00036E  8E20 0020               SRDA  2,32(0)                               
.   000372  4840 A012               LH    4,18(0,10)              PGMLIT AT +10
.   000376  8E40 0020               SRDA  4,32(0)                               
.   00037A  1A24                    AR    2,4                                   
.   00037C  1E35                    ALR   3,5                                   
.   00037E  47C0 B16E               BC    12,366(0,11)            GN=18(000386)
.   000382  5A20 C004               A     2,4(0,12)               SYSLIT AT +4 
.   000386                 GN=18    EQU   *                                     
.   000386  5030 8000               ST    3,0(0,8)                WS-COMP   
   


Dave
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue May 02, 2006 5:12 am
Reply with quote

Afew other points:

As David has illustrated in some of his examples, mixing data formats is usually not a good idea, but sometimes it can avoid confusion without adding too much overhead. You'll have to make that determination.

I've never taken the time to check, but I remember hearing that non-integer math adds significant overhead when using COMP data types.
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 COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts convert alphanumeric PIC X(02) to hex... COBOL Programming 3
Search our Forums:

Back to Top